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