Set the flag first then print
pojuse strict; my $flag = 0; my $few = shift || 3; while (<DATA>) { $flag = $few if (/Update certificate/); print $_ if ($flag-- > 0); }
In reply to Re^3: How to print 5 lines below after a regex match
by poj
in thread How to print 5 lines below after a regex match
by new2perl2016
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |