Two things. First, your use of
EXPR .. 1 contains an error. If
$. == 1, the flip-flop will fail prematurely. Better would be to use a regexp that can never match. Second, an easy way to "reset" the flip-flop is by using eval:
sub blah {
my $look_for = shift;
my (undef, @a) = eval 'grep {$_ eq $look_for .. /(*FAIL)/} @_';
@a;
}
The eval forces a new flip-flop operator each time.