...
sub convert
{
my $re = shift;
$re =~ s( \\ ( \\ | C\{ (?>\s*) ((?>\w+)) (?>\s*) \} ) )
{
defined $2
? "(?{\$~{$2}=\$^N})"
: "\\"
}xeg;
"(?{undef(%~)})" # clear the %~
.$re
."(?{\$~{\$_}=\${\$_} for(1..\$#+)})"; # add the numbered matches
}
...
my $re = qr/(\w+)\C{baz}(?: - (\w+)\C{qux})?(\+\d+)/;
"three - four - five+89" =~ $re;
print "baz=$~{baz}, qux=$~{qux}, $~{3}\n";
####
my $re = qr/(?\$bar=\w+) - (?\$qux{not}=\w+)/;
##
##
...
sub convert
{
my $re = shift;
$re =~ s<\(\?\\\$([^=]+)=([^)]*)\)><($2)(?{\$$1=\$^N})>g;
$re
}
...
##
##
my $re = qr/...(?\$var=a(\d+|\w-\w+)b).../;