Aaron J Mackey schreef:
> 
> $_ = "2aaa";
> @d = m/(\d+)(a){\1}/;
> # @d = (2, a, a);
> 
> That construct doesn't seem to work; Is there a way to get it to work?

Even if it would work, the output would be different. Compare:

@d = m/(\d+)(a){2}/;
print "@d";   # output: 2 a

The parentheses around a return only one match, regardless of the number
within the {}.

You can come close by using the (??{ code }) construct:

@d = m/(\d+)((??{"a{$1}"}))/;
print "@d";   # output: 2 aa

Apparently, ()'s inside the (??{}) do not capture what they match, or
else

@d = m/(\d+)(??{'(a)'x$1})/;

would be exactly what you want.

Eugene

Reply via email to