in reply to Capturing the first and last line of a file ?

use File::ReadBackwards; open(my $fh, "test") or die("ack - $!"); my $first = <$fh>; close $fh my $last = File::ReadBackwards->new("test")->readline;
See. File::ReadBackwards for more info on the module and Performing a tail(1) in Perl (reading the last N lines of a file) for a good node on reading the last line of a file.
HTH

_________
broquaint