in reply to Reading the last line of a file in a Pure Way.
my $last; { local $_; open FILE, "<myfile" or die "opening myfile: $!\n"; $last = $_ while <FILE>; close FILE; # last line in $last. }
((added:) ...read the file, keep track of each line read in $last. At the end, $last will contain the last line successfully read.)
|
|---|