Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

(japhy) Re: Re: Re: regex for assignment

by japhy (Canon)
on Feb 27, 2001 at 04:44 UTC ( [id://60994]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://60994]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-03-29 02:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found