Doesn't say it's deprecated, though.
Still, is there ever a time $1 won't work?
I stumbled on this example at
http://tutorials.findtutorials.com/read/category/80/id/99/p/
(bottom of the page)...

<snip>

Finally, in our tour of regular expressions, let's look again at backreferences. Suppose you want to find any repeated words in a string. How would you do it? You might think about doing this:

if (/\b(\w+) $1\b/) { print "Repeated word: $1\n";}

Except, this doesn't work, because $1 is only set when the match is complete. In fact, if you have warnings turned on, you'll be alerted to the fact that $1 is undefined every time. In order to match while still inside the regular expression, you need to use the following syntax:

if (/\b(\w+) \1\b/) { print "Repeated word: $1\n";}

However, when you're replacing, you'll get a warning if you try and use the \<number> syntax on the wrong side. It'll work, but you'll be told "\1 better written as $1 ".

</snip>

Tom

_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to