The flip-flop operator returns a special value when the flop condition is true. Take advantage of it to determine that it's time to process what you have accumulated.
my $found; while (<>) { my $i = /ABCD/ ... /EFGH/; if ($i) { $found .= $_; if ($i =~ /E/) { print "========\n"; print $found; $found = ''; } } }
You can also achieve the same with the following:
while (<>) { my $i = /ABCD/ ... /EFGH/; print "========\n" if $i == 1; print if $i; }
In reply to Re: Perl Range operator question
by ikegami
in thread Perl Range operator question
by jhuijsing
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |