Beruflich Dokumente
Kultur Dokumente
Perl
Programming
Module 1
Perl Basics
What is Perl?
Control Structures
Comparison operators
Looping
Perl loops
$num1=6;
while ($num1 < 12)
{
print $num1;
$num1++;
}
• This loop will print the values of $num1
starting at 6 and going through to 11. The
loop fails when $num1 is incremented to 12.
Exercise
• The line
$line=<MFILE>;
will read a whole line of input from the MFILE
filehandle. If there is nothing to read, the value
“undef” (for undefined) is returned.
• You can use loops to read through an entire
file. To test whether the value undef has been
detected, use the “defined” keyword:
while (defined($line=<MFILE>)) …
A shortcut for reading lines
Functions (Subroutines)
Subroutines
Functions and Perl
References
References