my $string = "Bar"; $sting =~ /Foo(?{ print "Found a Foo\n" })|Bar(?{ print "Found a Bar\n" })|Baz(?{ print "Found a Baz\n" })/;