On Jul 26, 2005, at 5:35 PM, Abigail wrote:
On Tue, Jul 26, 2005 at 05:37:39PM +0100, Nicholas Clark wrote:
So is "wantarray's value is only specified within a subroutine or
method
which was called directly by other perl code" true?
No.
$ perl -wle 'print eval "wantarray"'
1
$
No subroutine, no method.
The eval is still a block scope from which one can return, so wantarray
indicates the context provided to the eval block, not to the -e script,
and print provides it a list context.
Compare:
$ perl -wle 'print eval { eval { wantarray } }'
1
$ perl -wle 'print eval { eval { wantarray }; "" }'
Useless use of wantarray in void context at -e line 1.
$
It would be helpful to have a term which means 'block from which one
can return', i.e. a sub or eval. Suppose we use the word 'frame'.
Then I'd propose the statement above except with 'frame' instead of
'subroutine or method'.
Josh