develooper Front page | perl.perl5.porters | Postings from October 2005

[perl #37289] Erratic return of hashref from sub

Steven Schubiger via RT
October 2, 2005 04:14
[perl #37289] Erratic return of hashref from sub
Message ID:
> [ - Tue Sep 27 16:49:52 2005]:
> Using an explicit return, as suggested by MGS, instead of the + also works.
> Thanx.
> Would it be possible for Perl to output a warning in such cases?

Implicit return can work, although explicit ones should be preferrably used.
For an though programmer, these warnings would be superfluous and at 
best annoying.

Besides that, if agreed upon, it would almost inevitably lead to an addition 
of warnings to the extent of being unmanagable due to other functions that 
have such 'unexpected' side-cases.

I could imagine adding this functionality to the strict pragma along with
the keyword 'return' - so "no strict 'return'" would disable that behavior.
But I doubt that would break many existing scripts/modules out there; another,
slightly less harmful, approach would be to leave 'use strict' as it is and 
make the behaviour optional. Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About