in reply to Re: Module Announcement: Perl-Critic-1.01
in thread Module Announcement: Perl-Critic-1.01
Well, whenever being explicit breaks things. return; and return undef; is NOT the same thing! It does return the same thing in a scalar context, but a very different thing in a list one. So for example
does print the greeting. Because the function returns a list containing one element, the undef. And once you assign the list to an array and evaluate that assignment in scalar context you get the number of elements in the list and thus a true value. Probably not what you wanted, right?sub foo { return undef; } if (@results = foo()) { print "Helo jettero :-P\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Module Announcement: Perl-Critic-1.01
by Rhandom (Curate) on Jan 26, 2007 at 19:32 UTC | |
by Jenda (Abbot) on Jan 27, 2007 at 00:52 UTC | |
by Rhandom (Curate) on Jan 29, 2007 at 19:07 UTC | |
by Jenda (Abbot) on Jan 29, 2007 at 22:43 UTC |