more useful options | |
PerlMonks |
RE: Scope of regular expression variablesby nuance (Hermit) |
on Aug 29, 2000 at 22:58 UTC ( [id://30190]=note: print w/replies, xml ) | Need Help?? |
The behaviour you are seeing is caused by the fact that $1 and friends are only overwritten by a successfull match or substitution that has backreferences. So your code says check this expressions against $1, if that matched then and only then will $1, $2 & $3 be given the new values. If it didn't match, then there is no statement to overwrite $1, so your that your else clause is checking the same value of $1. Nuance
In Section
Seekers of Perl Wisdom
|
|