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.
For details, see the description of @- in perlvar.if ( /(foo)|(bar)|(baz)/ ) { print "$#-\n"; }
In Section
Seekers of Perl Wisdom