in reply to managing log files
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; } } }
|
|---|