I excitedly downloaded and compiled 5.10 yesterday, and tried out some of the new features.
There's one, though, that did not work as I expected:
#!/opt/perl/bin/perl
use strict;
use warnings;
use 5.010;
my $str = 'Digits: 123689';
if ($str =~ m{Digits: \s* (?<digit>\d)+ }x) {
say 'Digits: ', join(', ', @{$-{digit}});
}
This prints, I mean, says:
Digits: 9
So it appears that on a quantified named capture, only the last match is captured in
%-.
This seems very counterintuitive to me. Isn't the whole point of
%- that it captures all matches?
Of course, I can do something like:
(?<digit>\d)? (?<digit>\d)? (?<digit>\d)? (?<digit>\d)? (?<digit>\d)?
+(?<digit>\d)? (?<digit>\d)? (?<digit>\d)? (?<digit>\d)? (?<digit>\d)?
which works, but that's just plain silly...
Is this a bug? Or simply not an implemented feature? Or is there a good reason why
%- does not capture this?
Thanks,
- Michael