Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re^2: Difference between $1 and \1. (perldoc -v)

by LanX (Chancellor)
on Dec 27, 2012 at 12:20 UTC ( #1010510=note: print w/replies, xml ) Need Help??

in reply to Re: Difference between $1 and \1.
in thread Difference between $1 and \1.

> perldoc -v $1

before people start complaining, this doesn't work with 5.10!

       -v   Describes search for the item in detail (verbosely).

And when using Linux, better care about hiding $1 from bash-expansion.

perldoc -v '$1'

Cheers Rolf

) dunno when it was introduced...



Up to 3.14_05, the switch -v was used to produce verbose messages of perldoc operation, which is now enabled by -D.

ehm 3?

Replies are listed 'Best First'.
Re^3: Difference between $1 and \1. (perldoc -v)
by rbala (Acolyte) on Dec 27, 2012 at 14:08 UTC
    Thanks all! From your replies I understand that $1 , $2 type of variables will not contain any value or contain only, old match values of first or second paranthesis from any previous regex matching , unless the pattern matching is complete and if that matching is successful. Opposed to this is \1 which stores first paranthesis value even before the entire pattern is matched , so that it has a defined value in the matching pattern itself and hence provides expected results. Hope my understanding is correct. Correct me if any concerns for you...!!!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1010510]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2017-05-25 11:36 GMT
Find Nodes?
    Voting Booth?