in reply to Re^3: Why do I (sometimes) get a REF ref and not a SCALAR ref?
in thread Why do I (sometimes) get a REF ref and not a SCALAR ref?
outputsperl -E '@arr=(\\$x,\\@x,\\%x);say \\$x;say \\@x;say \\%x'
andREF(0x8e8f58) REF(0x8e8f58) REF(0x8e8f58)
outputsperl -E '@arr=(\\$x,\\@x,\\%x);say join"\n",\\$x,\\@x,\\%x'
andREF(0xdc3f58) REF(0xdc3e38) REF(0xde0618)
outputsperl -E '@arr=(\\$x,\\@x,\\%x);say $arr[0];say $arr[1];say $arr[2]'
I think what's going on is that we're getting the address of a temporary variable. When they are all in the same statement, you need three temporary spots; when in different statements, you just reuse your scratch space.REF(0x19b4d48) REF(0x19b4b98) REF(0x19d13e8)
Still doesn't answer the 'REF' question, though...
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
|
|---|