in reply to Re^2: Read and skip a line
in thread Read and skip a line

Most perl programmers would do this the way Corion indicated.

Your logic is incorrect - here is a version using a "for loop" that you seem to want - , but coded in a more idomatic manner:

use strict; use warnings; my $filename = shift; open my $file, "<", Filename or die "Cannot open $filename: $!"; chomp (my $lastrecord = <$file>); # Reads in the first record for (my $rec = 1; $rec <= $lastrecord and not eof($file); $rec++) { chomp(my $line = <$file>); print "Line $rec: $line\n"; };
There is a small,subtle potential problem inherent in the code above - not corrected in order to maintain simplicity : the $line read in may be empty at EOF.

UPDATE:Please do not delete code/comments after posting them - it makes responses like mine look out of context. It also prevents others from learning because context disappears.

             All great truths begin as blasphemies.
                   ― George Bernard Shaw, writer, Nobel laureate (1856-1950)