in reply to Re^2: [SOLVED] Return statement in subroutine(s) is necessary when not returning anything?
in thread [SOLVED] Return statement in subroutine(s) is necessary when not returning anything?

I disagree. A large part of my affection for Perl is its terseness. It doesn't force you to do things that are obvious enough for the compiler so obvious enough for a good dev. Verbosity can be an impediment to communication; especially in technical matters. Back to the OP's example–

sub ohai { print "OHAI"; return; }

That is technically "wrong." It prevents you from being able to use the sub like this do_something() if ohai(); It makes the sub less useful (Update: and harder to test). To fix that, you would report on success. That RFC:SHOULD look like:

sub ohai { return print "ohai"; }

How good a practice does that appear to be? Looks foolish to me. I much prefer the implicit return (when it's sensible, it's not always) than the explicit being recommended.

  • Comment on Re^3: [SOLVED] Return statement in subroutine(s) is necessary when not returning anything?
  • Select or Download Code