...if I use do on a file, I get a context for wantarray to work on even if it's at the top level of the file.
I'm not sure what you mean by this, but here's an example in which wantarray doesn't seem to work at the top level:
...though the above was obtained with v. 5.8.4. But even if the output above had been "yes", it wouldn't have contradicted the docs. The docs are simply saying that the behavior is unspecified, i.e. don't write code that depends on this behavior because it is liable to be not portable or being broken by future releases of Perl. It seems very clear to me.% perl -wle 'my @x = do { wantarray ? q(yes) : q(no) }; print $x[0]' no
the lowliest monk
In reply to Re: wantarray documentation in 5.8.7
by tlm
in thread wantarray documentation in 5.8.7
by polettix
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |