Almost. Your code is not qualifying the state before changing it.
Maybe like this:
my @fn = (\&doOtherProcessing, \&doStage1, \&doStage2, \&doStage3); my $fn = 0; while (<DATA>) { if ($fn == 0 and /for/) {$fn = 1} if ($fn == 1 and /their/) {$fn = 2} if ($fn == 2 and /fruit/) {$fn = 3} if ($fn == 3 and /lazy/) {$fn = 0} $fn[$fn]->($_); }
In reply to Re^2: Multi-stage flip-flop?
by RonW
in thread Multi-stage flip-flop?
by RonW
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |