in reply to Iteration condition...

I'm probably pounding a thumbtack with a sledgehammer, here, but what about something like (and this assumes that $Start and $Finish don't change through the code operation):
my $machine = {$Start => \&do_this, $Finish => \&do_that}; my $doit = \&do_this; foreach my $line(@Input) { my $func = $machine->{$line}; $doit = $func if (defined $func); $doit(); }
Now, this is totally untested but something like this should work...
--
Wade

Replies are listed 'Best First'.
Re^2: Iteration condition...
by moritz (Cardinal) on Mar 31, 2008 at 15:55 UTC
    note that $Start and $Finish are regexes in the OP, so you can't just use them as if they were strings (as hash keys), and you can't assume that the whole string in $line matches. (It's enough if a substring matches, unless the regexes contain anchors).
      You're exactly right, of course -- I didn't fully caveat the code (hey, this guy used caveat as a verb -- can he do that?). I was just trying to provide an alternative line of thought. 8o)
      --
      Wade