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

Re^2: Determining the fully qualified name of a global variable. ('return undef')

by LanX (Chancellor)
on Jan 27, 2013 at 09:28 UTC ( #1015570=note: print w/ replies, xml ) Need Help??


in reply to Re: Determining the fully qualified name of a global variable.
in thread Determining the fully qualified name of a global variable.

> 'return undef;' is redundant. From return:

If no EXPR is given, returns an empty list in list context, the undefined value in scalar context, and (of course) nothing at all in void context.

Sorry for nitpicking but it's not equivalent. =)

In list context  return undef is true, cause a one-element list (undef) will be returned.

DB<106> sub tst {return undef} DB<107> print "true" if ( @list=tst() ) true

But empty returns are always false:

DB<108> sub tst {return} DB<109> print "true" if ( @list=tst() ) DB<110>

Cheers Rolf


Comment on Re^2: Determining the fully qualified name of a global variable. ('return undef')
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2016-02-08 11:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?





    Results (276 votes), past polls