a not so perfect solution , but might work
#!/usr/bin/perl use strict; use warnings; my @array; my $PreviousLines = 4; while (<DATA>) { chomp; if (/xyz/) { print join "\n", @array; print "\n\n"; }else{ push @array, $_; if (@array > $PreviousLines ) { # delete first element splice @array, 0,1; } } }
In reply to Re: managing log files
by ahmad
in thread managing log files
by itsmeman2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |