in reply to Re: how to remove matched multi lines
in thread how to remove matched multi lines
It is instructive to look at what the flip-flop operator actually generates. Consider:
use strict; use warnings; my $str = '[][ab]c[]d'; for my $chr (split '', $str) { my $result = $chr eq '[' .. $chr eq ']'; printf "%-2s %s\n", $chr, $result; }
Prints:
[ 1 ] 2E0 [ 1 a 2 b 3 ] 4E0 c [ 1 ] 2E0 d
Note the iteration count for 'true' and that the last iteration has a trailing 'E0'. Your 'missing blank line' problem is just like the '][' case above - you need to either retest the ending condition and exclude it, or you can save the flip-flop result and test that.
If you haven't seen it already, you may find Flipin good, or a total flop? of interest too.
|
|---|