|
COMP 2400 Software Tools
Goals:
- Understand Perl
file handling
- Opening a file for input
- Opening a file for output
- Opening a file for appending
- Open a file and place # as the first
character for all lines in that file
- Special variable $_ for file processing
- Control structures and looping (foreach,
while, for)
Useful commands/tips:
- incrementing string variable $i = "000";
makes it equal to "001"
- Common pattern to loop through each line
of file where the file handle is INFO ($_ refers to the current
line):
while (<INFO>)
{
print $i++ . " $_";
}
Useful Links:
Online Tutorial:
|