
All Perl subroutines may be used in an expression as if they returned a value, but Perl subroutines are not required to have an explicit return statement. If control exits a subroutine by some means other than an explicit return statement, then the value actually returned is the last value computed within the subroutine. This behavior is never intended by the developer (else she would have added a return statement) and may potentially be information that is private to the subroutine.
...
EXP01:EX1: A function need not have an explicit return value if it is only used in a program that never requests its return value.
Risk Assessment
Attempt An attempt to read the return value of a function that did not return any value can cause data encapsulated by the function to leak.
...
Tool | Diagnostic |
---|---|
Perl::Critic | Subroutines::RequireFinalReturn |
Bibliography
...
"Implicit Returns," p. 197 | |
---|---|
[CPAN] | Elliot Shank, Perl-Critic-1.116 Subroutines::RequireFinalReturn |
...