Please see Python code, then the Perl equivalent:
import re
r = re.compile(r'(?P<A> a (?P<B> b))', re.X)
m = r.search('ab')
for k in m.groupdict():
print k, '=>', m.group(k) # 'A => ab'
# 'B => b'
print m.group('A') # 'ab'
print m.group('B') # 'b'
Perl equivalent:
'ab' =~ /(?<A> a (?<B> b))/x;
print "$_ => $+{$_}\n" for (keys(%+)); # 'A => ab'
# ... nothing, thats it
print "$+{'A'}\n"; # 'ab'
print "$+{'B'}\n"; # 'b'
Perl doesn't enumerate all the keys if a named capture is nested within another. But it it clearly holds the correct value 'b' with the correct key 'B' in the hash.
Is this a "feature" or a bug? ;)