in reply to Re^2: wantarray - surprise behaviour
in thread wantarray - surprise behaviour
What happens inside the subroutine that wantarray() is in is absolutely irrelevant to what wantarray() reports.
There are 3 contexts that a subroutine can be called in:
Anything you can dream up that can be assigned into fits into one of those categories. But dont trick yourself into thinking something like this will try a list assignment:blah(); # void $x = blah(); # scalar @x = blah(); # list
So, even though $x is an arrayref, an arrayref is NOT a list, its a scalar. A reference to be specific.my $x = []; # $x is now an (empty) arrayref $x = blah(); # $x is a scalar - wantarray reports 0
|
|---|