in reply to Re: Best way to extract RE backreferences
in thread Best way to extract RE backreferences
Strictly speaking the parens around the match itself aren't necessary; it's already in list context.
% perl -le '$_="abcde";my($z,$y,$x)=/(b)(c)(d)/;print "$x$y$z"' dcb
However if you wanted to save only a subset of the saved subexpressions, the ()'s around the match will let you use brackets to get a slice (but then you might be better off using non-capturing parens instead).
my( $y, $x ) = (/(b)(c)(d)/)[1,2];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Best way to extract RE backreferences
by dragonchild (Archbishop) on Feb 05, 2003 at 21:11 UTC | |
by Aristotle (Chancellor) on Feb 06, 2003 at 12:33 UTC |