in reply to Question perlcritic ProhibitExplicitReturnUndef
Therefore, Perl::Critic's warnings should also not be taken as strict rules that you must comply with.
Perl::Critic gives you an explanation of why it objects to return undef;. Use that explanation to determine whether it is appropriate for you to return undef; in this case or not.
Also note that the Perl::Critic explanation says, "The solution is to just use a bare `return' statement whenever you want to return failure." If your intent is to return an undefined value rather than to indicate failure, then there's no problem with your return undef;, is there? (In that case, I would advise adding a comment stating that this is the intent so that a future maintainer who subscribes to PBP doesn't break your code in an attempt to "fix" it. Mentioning in the sub's documentation that a return value of undef is not intended to indicate failure would also be wise.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Question perlcritic ProhibitExplicitReturnUndef
by mje (Curate) on Feb 06, 2009 at 16:57 UTC |