use Tie::IxHash; tie my %dt, 'Tie::IxHash', qr/one/ => \&handle_one, qr/two/ => \&handle_two; my $c="trigger one trigger two"; sub handle_one { print "one: ", shift, "\n"; } sub handle_two { print "two: ", shift, "\n"; } foreach (keys %dt) { $c =~ /\G.+?($_)/gcs and $dt{$_}->($1); }