use warnings; use strict; print "Using Perl $]\n\n"; print "Result using DATA:\n\n"; doRead (*DATA); print "\nResult using file handle:\n\n"; open my $FH, '<', 'noname.pl'; doRead ($FH); close $FH; sub doRead { my $FH = shift; while (! eof $FH) { my $lineStart = tell $FH; my $line = <$FH>; chomp $line; if ($line =~ /^NEWTABLE/) { print "Found at $lineStart: >$line<\n"; seek $FH, $lineStart, 0; $line = <$FH>; chomp $line; print "Reread as >$line<\n"; } } } __DATA__ First line Second line NEWTABLE - third line Fourth line #### Using Perl 5.008007 Result using DATA: Found at 627: >NEWTABLE - third line< Reread as >< Found at 628: >NEWTABLE - third line< Reread as >< Found at 629: >NEWTABLE - third line< Reread as >NEWTABLE - third line< Result using file handle: Found at 629: >NEWTABLE - third line< Reread as >NEWTABLE - third line<