I don't know where you are going with this but the
$^N variable, but it might be what you are looking for (granted I am aware that it does not get you the number). According to
perlvar:
This is primarily used inside (?{...}) blocks for examining text recently matched. For example, to effectively capture text to a variable (in addition to $1, $2, etc.), replace (...) with (?:(...)(?{ $var = $^N }))
By setting and then using $var in this way relieves you from having to worry about exactly which numbered set of parentheses they are.
-enlil