You don't have a loop around the /g match, so it only matches once and uses the first matching alternative, "a".
The following loops over the string and outputs %+ whenever it matches something:
> perl -wE"while ('abcde'=~m[(?<a>a)|(?<b>b)|(?<c>c)|(?<d>d)]g){say'-- +';say for keys%+}" -- a -- b -- c -- d
I don't think that %+ will ever be filled with keys from more than one part of an alternation, so you'll never find more than one key in your example. To get all keys you'll likely need to introduce an explicit ordering or enumerate the alternatives.
In reply to Re: Named Captures
by Corion
in thread Named Captures
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |