in reply to Hope a subroutine will return undef by default
A naked return; at the end is IMHO the best workaround.¹
Of course one could write a module which parses all functions during one of the BEGIN-phases and wraps a naked return if there is no return as final statement, but this is IMHO far too vulnerable for production. ( update and wouldn't work for dynamically defined functions)
Cheers Rolf
( addicted to the Perl Programming Language)
¹) It returns an empty list in list context which produces an undef in scalar context.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Hope a subroutine will return undef by default
by tobyink (Canon) on Feb 11, 2014 at 22:59 UTC | |
by LanX (Saint) on Feb 11, 2014 at 23:04 UTC | |
by choroba (Cardinal) on Feb 11, 2014 at 23:56 UTC | |
by tobyink (Canon) on Feb 11, 2014 at 23:47 UTC | |
by LanX (Saint) on Feb 11, 2014 at 23:58 UTC |