Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1015570]
[ambrus]: Corion: some of these stupid syntax highlighters assume that too. just look at the table in http://perldoc. functions/pack. html for example.
[haukex]: ..."yet" ;-) I haven't had to deal with Dist::Zilla yet but I've heard about how it's a big setup
[ambrus]: I really don't like automagic stuff. I'm happy when computers do exactly what I tell them, even if that means they sometimes do the wrong thing.
[ambrus]: And I don't much like syntax highlighters. If you need a syntax highlighter to understand your code, then your code is written unclear.
[ambrus]: And if you need a syntax highlighter to color parenthesis green and numbers black and letters blue, then you're using the wrong font.
[ambrus]: I have to tolerate syntax highlighters when other people use them, but I don't use them myself. And sorry for the rant.

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (14)
As of 2017-02-27 12:45 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (385 votes). Check out past polls.