in reply to Re^2: Difference between $1 and \1. (perldoc -v) in thread Difference between $1 and \1.
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...!!!
|