my $MAX = 5; local $_; OUT: while ( defined ( $_ = <LOG> ) ){ push @lines, $_; shift @lines if @lines > $MAX; if ( /bla bla/ ) { print @lines, $_; for ( 1 .. $MAX ) { last OUT unless defined ( $_ = <LOG> ); print; } } }
In reply to Re: grab 'n' lines from a file above and below a /match/
by borisz
in thread grab 'n' lines from a file above and below a /match/
by barathbr
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |