in reply to pattern matching only last line of a file and then copy 10 lines above till end

use strict; use warnings; use File::ReadBackwards ; my $bw = File::ReadBackwards->new( 'file' ) or die "can't read 'log_file' $!" ; my @lines; $lines[0] = $bw->readline; if ( $lines[0] =~ /pattern/ ) { for (1..9) { $lines[$_] = $bw->readline; } } @lines = reverse @lines; print "@lines";


holli, /regexed monk/
  • Comment on Re: pattern matching only last line of a file and then copy 10 lines above till end
  • Download Code