Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: Module Announcement: Perl-Critic-1.01

by ikegami (Pope)
on Jan 26, 2007 at 16:50 UTC ( #596753=note: print w/ replies, xml ) Need Help??


in reply to Re: Module Announcement: Perl-Critic-1.01
in thread Module Announcement: Perl-Critic-1.01

Maybe it's trying to encourage you to specify the return value explicitly, as in

return undef;
or
return ();

Update: Here's a table of the differences:

return undef; return (); return;
scalar $sv = foo(); undef undef undef
boolean if (foo()) { } false false false
string '' . foo() '' with warning '' with warning '' with warning
number 0 + foo() 0 with warning 0 with warning 0 with warning
list my @a = foo(); ( undef ) ( ) ( )
boolean list assignment if (my @a = foo())
if (my ($sv) = foo())
if (() = foo())
true false false
scalar list assignment my $sv = () = foo() 1 0 0

Note: How list assignments are treated in scalar context is what allows
while (my ($key) = each(%hash))
to work even if there's a key named 0.


Comment on Re^2: Module Announcement: Perl-Critic-1.01
Select or Download Code
Re^3: Module Announcement: Perl-Critic-1.01
by jettero (Monsignor) on Jan 26, 2007 at 16:56 UTC

    Maybe it's trying to encourage you to specify the return value explicitly...

    Actually, exactly the opposite. It says you shouldn't explicitly return undef because you might actually mean return (), and that return; dwims.

    -Paul

Re^3: Module Announcement: Perl-Critic-1.01
by Anonymous Monk on Jun 23, 2007 at 11:01 UTC
    "return;" is identical to "return();"

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (11)
As of 2014-07-23 22:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (154 votes), past polls