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

use strict; open (FOO, "test") || die "ERROR Unable to open test: $!\n"; my $first = <FOO>; my $last = $first; while (<FOO>) {$last = $_} close FOO; print "$first\n$last\n";
There is a lot of copying but no more than one line is stored in memory.
update - added my $last = $first; in case file only has one line.

--

flounder