tie @array, 'Tie::File', $fname or die "Can't tie $fname: $!"; my $first = shift (@array); # First line of the file my $last = pop (@array); # Last line of the file untie @array;