On 2005-05-17 14:14, "Peter Haworth" <[EMAIL PROTECTED]> wrote:\
> 
> Does numbering of captures after an alternation continue as if the
> alternative with the most captures matched?
> 
>     #   $1    $1  $2    $3, even if (a) matched
>   rx/ [ (a) | (b) (c) ] (d) /;

I thought that was still like Perl5:

>     #   $1    $2  $3    $4
>   rx/ [ (a) | (b) (c) ] (d) /;

The *numbering* is based on the regex; the *values* are based on the actual
match.

What's changed in the Perl6 design, AIUI, is nested captures.  Given this:

> rx/ (a (b (c d) e) f) /

In Perl5, $1 is "abcdef", $2 is "bcde", and $3 is "cd".  In the proposed
Perl6 model, there is no $2, just $1 (an object which stringifies to
"abcdef", $1.1 (an object which stringifies to "bcde"), and $1.1.1 (an
object which stringifies to "cd".




> 

> 
> 
> If you explicitly number the first capture in one alternative, does that
> affect the numbering of the other alternatives?
> 
>     #       $4    $4
>   rx/ [ $4:=(a) | (b) ] /;
> 
> 
>> Note that, outside a rule, C<@1> is simply a shorthand for C<@{$1}>
> 
> Is @/ also a shorthand for @{$/} ?
> 



Reply via email to