in reply to How to enforce void context in Reply?

G'day docdurdee,

Using return without arguments would be how I would do this. The Syntax::Feature::Void documentation states this to be the functional equivalent of what it's doing. Is there a reason you can't do the same?

Please supply code examples of what you're doing, an explanation of how it's not achieving what you want at present, and a description of the actual result you're aimimg for. This clarification should help in providing a better answer.

-- Ken

  • Comment on Re: How to enforce void context in Reply?

Replies are listed 'Best First'.
Re^2: How to enforce void context in Reply?
by AnomalousMonk (Archbishop) on May 19, 2015 at 02:27 UTC

    Further to kcott's reply above, here's an experiment that may make the operation of function call return context more clear:

    c:\@Work\Perl\monks>perl -wMstrict -le "sub S { print ! defined wantarray ? 'void' : wantarray ? 'list' : 'sc +alar'; } ;; sub T { print 'non-return: '; S; print 'return: '; S; } ;; sub U { print 'SCALAR ----'; my $scalar = T; print ''; print 'LIST ----'; my @ra = T; print ''; print 'VOID ----'; T; print ''; } ;; U; " SCALAR ---- non-return: void return: scalar LIST ---- non-return: void return: list VOID ---- non-return: void return: void
    See also wantarray and Context in Perl.


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