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";
In reply to Re: pattern matching only last line of a file and then copy 10 lines above till end
by holli
in thread pattern matching only last line of a file and then copy 10 lines above till end
by ultibuzz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |