$_ = some line; my @tmp = @actions; while (@tmp) { my ($qr, $ops) = splice @actions, 0, 2; if (my @matches = /$qr/) { if (not defined $ops) { $default->(@matches); } elsif (ref $ops eq 'CODE') { $ops->(@matches); } elsif (ref $ops eq 'ARRAY') { $_->(@matches) for @$ops; } else { die "bad" } last; } }