in reply to Pass By Reference Inner Workings - Magic scalar operator
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Pass By Reference Inner Workings - Magic scalar operator
by diotalevi (Canon) on May 01, 2005 at 07:53 UTC | |
by davido (Cardinal) on May 01, 2005 at 08:12 UTC | |
|
Re^2: Pass By Reference Inner Workings - Magic scalar operator
by geekondemand (Scribe) on May 01, 2005 at 08:32 UTC | |
by davido (Cardinal) on May 01, 2005 at 08:45 UTC |