in reply to Re: How to enforce void context in Reply?
in thread How to enforce void context in Reply?

As noted in wantarray:

return unless defined wantarray; # don't bother doing more my @a = complex_calculation(); return wantarray ? @a : "@a";

Perhaps the OP is using a function that uses that strategy.

Replies are listed 'Best First'.
Re^3: How to enforce void context in Reply?
by Anonymous Monk on May 19, 2015 at 11:14 UTC
    That is detection not enforcement ... language barrier?

      If there is a sub foo that uses the above method of detecting when it is called in void context so that it can do less work; then that would be a reason the caller of sub foo (docdurdee) might want to enforce void context on it.

        But doesn't just calling  foo() in void context
            foo();
        enforce void context upon the invocation of foo()? What need for anything else?

        Is it ever possible to get a value directly returned from a subroutine invoked in void context, whether "enforced" or "natural" (as in the example above)? (Of course, it's always possible to indirectly return values from subroutines invoked in void context.)


        Give a man a fish:  <%-(-(-(-<