in reply to how to print first 5 lines of a file
The $. variable holds the current input line number of the last opened filehandle.
while ( $. < 5 ) { my $line = <DATA>; print "$. -> $line"; } __DATA__ one two three four five six seven
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.
|
|---|