http://www.perlmonks.org?node_id=765494


in reply to Re^2: Flip-flop won't DWIM
in thread Flip-flop won't DWIM

Your code prints "A B C D E F" for me, and I cannot see why it would print anything else.

This seems to work if you insist on using flip-flop:

$x = 1; print join " ", grep { $x..(($x=0) or /D/) } qw(A B C D E F);
However, you could copy stuff from List::MoreUtils.