mscha has asked for the wisdom of the Perl Monks concerning the following question:
This prints, I mean, says:#!/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}}); }
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?Digits: 9
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?(?<digit>\d)? (?<digit>\d)? (?<digit>\d)? (?<digit>\d)? (?<digit>\d)? +(?<digit>\d)? (?<digit>\d)? (?<digit>\d)? (?<digit>\d)? (?<digit>\d)?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Quantified named captures in 5.10
by webfiend (Vicar) on Dec 21, 2007 at 00:45 UTC | |
|
Re: Quantified named captures in 5.10
by educated_foo (Vicar) on Dec 21, 2007 at 06:18 UTC | |
|
Re: Quantified named captures in 5.10
by halley (Prior) on Dec 21, 2007 at 13:56 UTC | |
|
Re: Quantified named captures in 5.10
by mugwumpjism (Hermit) on Dec 21, 2007 at 06:22 UTC | |
|
Re: Quantified named captures in 5.10
by NetWallah (Canon) on Dec 22, 2007 at 04:08 UTC |