for my $file ( @ARGV ) { my $lastline = do { open my $pipe, '-|', tail => -1, $file or die "Can't spawn tail: $!\n"; <$pipe>; }; print $lastline; }