$Bill wrote:
> ... and \1 is deprecated for $1.

I believe that should read [thanks Greg!] "...and \1 is deprecated on the 
right
side of s///".  On the left side (as in any regexp), \1 and $1 differ. But 
as a holdover from sed, \1 means the same as
$1 on the right side of the subst.

\1 isn't the same as $1, in that
s/(.)\1//;
 
deletes duplicate chars, while;
s/(.)$1//;
 
depends upon the value of $1 - which, in this case'd be set *before* the 
subst got invoked.  On the right hand side, $1 is what we expect (the 
final matched text inside the first set of parens).

\1 (on the LHS) also can/will change during the course of a regex 
evaluation - as the 
parser/matcher works, \1 will take on different values during backtracking 

etc - though, in the end \1 is the same as $1. I've never understood it 
but I belive perl golfer/obfu folks can do strange and terrible things w/ 
the difference.

a

Andy Bach, Sys. Mangler
Internet: [EMAIL PROTECTED] 
VOICE: (608) 261-5738  FAX 264-5932

"If there be time to expose through discussion the falsehood and 
fallacies, to avert the evil
by the process of education, the remedy to be applied is more speech, not 
enforced silence." 
   Justice Louis Brandeis

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to