Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Answer: More than one way to do it???

by mirod (Canon)
on Dec 06, 2000 at 23:41 UTC ( [id://45292]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://45292]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2024-04-23 17:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found