in reply to Resetting a flip-flop operator

Flip-flop is magical, but not that much. You can use boolean expressions in it, so just change the right one:
next unless /^PP_START$/ .. (/^PP_END$/ || eof $HANDLE);
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: Resetting a flip-flop operator
by AppleFritter (Vicar) on Aug 06, 2015 at 11:14 UTC

    Ah! Yes, that works. Thanks!

    For the record and for the benefit of anyone else wondering the same thing, I've also tried experimenting with scoping, e.g. by moving the inner loop into a sub of its own. Turns out flip-flops maintain their state even across subroutine calls (which is likely what you'd expect anyway).

      Turns out flip-flops maintain their state even across subroutine calls
      Not if closures are involved:
      sub mk_flipflop { my ($start, $end) = @_; return sub { /$start/../$end/ } } for my $fh (@fhs) { my $ff = mk_flipflop(qr/^PP_START$/, qr/^PP_END$/); while (<$fh>) { $ff->() or next; # process line } }