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
orreturn undef;
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Module Announcement: Perl-Critic-1.01
by jettero (Monsignor) on Jan 26, 2007 at 16:56 UTC | |
|
Re^3: Module Announcement: Perl-Critic-1.01
by Anonymous Monk on Jun 23, 2007 at 11:01 UTC |