in reply to Re: More than one way to do it???
in thread More than one way to do it???

Actually you have to use \1 in the left part, you can't use $1, but you can use either \1 or $1 in the right part.

$1... cannot be used in the left part because it would be expanded (the $1 from the previous regexp) and usage of \1 in the right part is mildly frowned upon, mostly for stylistic reasons, as it is close to the \nn or \nnn notation for octal characters (although as usual Perl will DWIM by interpreting \12 as $12 if there were more than 12 captured expressions and as the character \12 otherwise).

  • Comment on Re: Answer: More than one way to do it???

Replies are listed 'Best First'.
Re: Re: Answer: More than one way to do it???
by slocate (Novice) on Dec 07, 2000 at 11:33 UTC
    This is correct. According to the Camel book, the right hand side of a substitution (//) is considered to be outside of the regex. So the "special" variable (i.e. \1) is treated as a "normal" scalar variable thus it can be interpolated there because this side functions as if it was a double quoted string.