in reply to Re: Re: regex for assignment
in thread regex for assignment

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.

japhy -- Perl and Regex Hacker

  • Comment on (japhy) Re: Re: Re: regex for assignment