On 31 Aug 2002 at 10:26, Piers Cawley wrote:
> > my $pattern = rx:w / $1:=(\S+) =<gt> $2:=(\S+) | > > $2:=(\S+) <lt>= $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 Apocalypse > get set for every capturing group independent of any named variable to > which they might also be bound. Not if those capturing groups have been renumbered. >From A5: > You can reorder paren groups by naming them with numeric variables: > > / $2:=(.*?), \h* $1:=(.*) / > If you use a numeric variable, the > numeric variables will start renumbering from that point, so > subsequent captures can be of a known number (which clobbers any > previous association with that number). So for instance you can > reset the numbers for each alternative: > > / $1 := (.*?) (\:) (.*) { process $1, $2, $3 } > | $1 := (.*?) (=\>) (.*) { process $1, $2, $3 } > | $1 := (.*?) (-\>) (.*) { process $1, $2, $3 } > / So binding to $1 etc is a special case. Your example never captures to $1..$4 but only to $1,$2 according to the renumbering. Note that it's actually called 'reordering/renumbering' instead of 'binding' in A5 for numeric variables. -- Markus Laire 'malaire' <[EMAIL PROTECTED]>