Problems? Is your data what you think it is? | |
PerlMonks |
(japhy) Re: Re: Re: regex for assignmentby japhy (Canon) |
on Feb 27, 2001 at 04:44 UTC ( [id://60994]=note: print w/replies, xml ) | Need Help?? |
merlyn's code uses the feature of list assignment in scalar context. This returns the number of elements being returned, which, in this case, is either 0 or 2. If the regex matches, then it returns $1 and $2, which means that $base and $ext get their values.
If the regex matches, then the two variables have values -- one can not be defined if the other isn't. Thus, merlyn's code does the right thing.
In Section
Seekers of Perl Wisdom
|
|