in reply to flip-flop operator and sequence number

How about
# variation with grep @a=qw(abc def ghi jkl mno pqr stu vwxyz); @g = grep /i/../u/, @a; for (1..$#g-1) { print "$g[$_]\n"; } # with map @a=qw(abc def ghi jkl mno pqr stu vwxyz); $flag=-1; sub go { print "$_\n" if ($flag>0); if ($_ =~ /i|u/) { $flag = $flag * -1 } } @g = map{ &go($_) => $_ } @a;
Just checked, it does not work if you say qw(abc start some things to print stop vwxyz) and look for start|stop but maybe that's not how you're using it. Does seem to work (checked the grep version) for qw(abc def start ghi jkl xxx mno pqr stu stop vwxyz).
Updated: You guys are so right. Kudos and votes to you.