in reply to Capturing the first and last line of a file ?
But in this case i would prefer head and tail if available#!/usr/bin/perl use warnings; use strict; open (FOO, "test") || die "ERROR Unable to open test: $!\n"; my $last; my $first = <FOO>; while (<FOO>) { $last = $_ } close FOO; print "\$first: $first"; print "\$last: $last";
head -1 test;tail -1 test
|
---|