in reply to Multi-stage flip-flop?

if I understand you right this can be achieved with a function mff() (multi_flip_flop) encasulating the logic and returning the stage number starting with 1.

 (\&doOtherProcessing, \&doStage1(), \&doStage2(),  \&doStage3())[ mff(/match1/, /match2/, /match3/, /match4/) ] ->()

or

if ( my $stage = mff(/match1/, /match2/, /match3/, /match4/) ) { if ( $stage == 1 ) { ... } elsif ( $stage == 2) { ... } ... } else { doOtherProcessing(); }

Cheers Rolf

(addicted to the Perl Programming Language and ☆☆☆☆ :)