in reply to Hope a subroutine will return undef by default

With sub rewriting, via attributes at least, you could arrange the sub to return undef: http://perltv.org/v/code-attributes presentation about code attributes by Steve B (video; via https://twitter.com/PerlWeekly). (Blame PerlMonks for links being just dead text.)

  • Comment on Re: Hope a subroutine will return undef by default

Replies are listed 'Best First'.
Re^2: Hope a subroutine will return undef by default
by hdb (Monsignor) on Feb 11, 2014 at 16:39 UTC

    Put your links into square brackets and they become alive...

      I did that first, with variations; got "Permission denied ... [Tt]ough beans". >-/

Re^2: Hope a subroutine will return undef by default
by qj1020 (Initiate) on Feb 11, 2014 at 17:23 UTC

    Thanks to you all for replying and giving me some thoughts. Will check out the link of the youtube video when I get more time.

    Here is more of the context: the subroutines (in the form of strings) was sent to my server on the fly for execution by a function under my control. I wish I can go and change the source of the subroutines to add an explicit "return undef" (the function is executed on my side in scalar context, so it's ok) but I can't. I am thinking of modifying the incoming subroutines, if it doesn't have a "return undef" before the ending of the subroutine, I will add one. But it's not elegant.