Keep It Simple, Stupid | |
PerlMonks |
Re^2: Module Announcement: Perl-Critic-1.01 (just a scalar)by tye (Sage) |
on Jan 26, 2007 at 20:55 UTC ( [id://596790]=note: print w/replies, xml ) | Need Help?? |
If your function normally returns scalars, then doing return; is likely the wrong thing to do. If your function at least sometimes returns lists, then return undef; is likely the wrong thing to do. The latter is covered by other replies. The reason that the former is wrong is because it can break code like:
And the problems with return undef; don't really apply to functions that only ever return a scalar because you don't write code like:
So, unless Perl::Critic checks whether your function ever returns other than 1 scalar elsewhere, I consider this warning to be encouraging a bad practice (rather than just pushing a reasonable practice too hard as many people will find many of the possible warnings, surely). - tye
In Section
Meditations
|
|