in reply to Difference between $1 and \1.
Checking the perl documentation, one could get glorious insight.
So, doing
perldoc -v $1 Update I: OR check perlvar
from the CLI gives:
So, doing
perldoc -v $1 Update I: OR check perlvar
from the CLI gives:
$<*digits*> ($1, $2, ...):
Contains the subpattern from the corresponding set of capturing
parentheses from the last successful pattern match, not counting
patterns matched in nested blocks that have been exited already.
These variables are read-only and dynamically-scoped.
While \1 :
is Backreference to a specific capture group or buffer. Please also check perlre.
It is also a good thing to note this Warning on \1 Instead of $1
UPDATE I: I was only checking this on Win OS. Thanks to LanX comments below.
If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Difference between $1 and \1. (perldoc -v)
by LanX (Saint) on Dec 27, 2012 at 12:20 UTC | |
by rbala (Acolyte) on Dec 27, 2012 at 14:08 UTC | |
by Anonymous Monk on Dec 27, 2012 at 14:11 UTC |
In Section
Seekers of Perl Wisdom