Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: array test question

by thpfft (Chaplain)
on Oct 27, 2002 at 16:37 UTC ( [id://208354]=note: print w/replies, xml ) Need Help??


in reply to array test question

Your test is sound, but the answer is probably that it depends what happens when 'assignment fails'. An array in boolean context (is there such a thing in perl?) will evaluate to true if it contains anything at all:

() is false (undef) is true (0) is true

so if it's coming from a sub that explicitly returns 0 or undef on failure, you'll end up with a populated array. The best thing to do is use just return, since return undef is true in list context. I dimly recall that there occasions when return () is dodgy in scalar context, too, but I can't remember what they are :(

hth

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-20 06:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found