Re: Regex stuff...

2002-08-31 Thread Markus Laire
On 31 Aug 2002 at 0:17, Piers Cawley wrote: > my $pattern = rx:w / $1:=(\S+) = $2:=(\S+) | > $2:=(\S+) = $1:=(\S+) /; > > @ary = m/<$pattern>/ > > how many elements are there in @ary? I can > make a case for 4 quite happily. Certainly that's what A5 seems to

Re: Regex stuff...

2002-08-31 Thread Markus Laire
On 31 Aug 2002 at 10:26, Piers Cawley wrote: > > my $pattern = rx:w / $1:=(\S+) = $2:=(\S+) | > > $2:=(\S+) = $1:=(\S+) /; > > Count the capturing groups. Looks like there's 4 of 'em to me. $1, $2, > $3 and $4 are automatic variables which, according to the Apocalyp

Re: Regex stuff...

2002-08-31 Thread Ken Fox
Piers Cawley wrote: > Unless I'm very much mistaken, the order of execution will > look like: > > $2:=$1; $1:=$2; You're not binding $2:=$1. You're binding $2 to the first capture. By default $1 is also bound to the first capture. Assuming that numbered variables aren't special, the orde

Re: Regex stuff...

2002-08-31 Thread Damian Conway
Piers Cawley wrote: > If I replace C<< ($key, $val) >> with > > @ary = m/<$pattern>/ > > and the match succeeds, how many elements are there in @ary? Zero. No explicit captures in that pattern. > Suppose you want to use a hypothetical variable to bind a name to > a capture