in reply to Re^2: better way to get last named capture group
in thread better way to get last named capture group

With numbered captures, defined( $1 ) tells us if a capture is part of the matching patch.

The equivalent with named captures would be exists( $+{ name } ).

To check which of a set, ( grep exists( $+{ $_ } ), qw( name1 name2 name3 ) )[ 0 ] could be used.

And of course, that simplifies to ( keys( %+ ) )[ 0 ] if only one named capture could have captured.