scalar is working for you, not because of its primary effect of forcing scalar context, but because of one of its secondary effects; of making your expression look like an expression, rather than just a bareword.
For example, you could also have said "my %x = %{+shift}". And that too would have worked.
The point is that %{shift} looks like a hash named "shift". %{+shift} looks like a dereferencing of the return value of the function named shift. And %{scalar shift} is recognized also by the compiler to be a set of function calls instead of just a literal variable name.
Dave
In reply to Re: Pass By Reference Inner Workings - Magic scalar operator
by davido
in thread Pass By Reference Inner Workings - Magic scalar operator
by geekondemand
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |