http://qs1969.pair.com?node_id=524769


in reply to Finding out which of a list of patterns matched

$#- gives the number of the last capture in the last regex that was successful. With simple alternation as in this case you can just make each alternative a caputure.
if ( /(foo)|(bar)|(baz)/ ) { print "$#-\n"; }
For details, see the description of @- in perlvar.