in reply to Re: Modifying values by reference: what works and what doesn't
in thread Modifying values by reference: what works and what doesn't

This code shows that you were not that precise :-) (Update: See below reply from phaylon, sounds like I have misunderstood what he said, and that was my fault. I up voted both of his posts.)

use strict; use warnings; my $ref = {"a" => 1}; print $ref, "\n"; foo($ref); sub foo { my $ref = shift; print $ref, "\n"; $ref = { "all" => "new" }; print $ref, "\n"; }

Run it, you will see that the first two print statements print the same addresses, but not the third one.

Replies are listed 'Best First'.
Re^3: Modifying values by reference: what works and what doesn't
by phaylon (Curate) on Aug 25, 2005 at 21:03 UTC
    That's actually what I've meant ;) Though I'm not a native speaker, so I may have screwed it up a byte. I meant it copies the contents of the scalar, the reference. That results in a second reference (in counting refcounts) to the same address.

    Sorry to confuse, if I have :)

    Ordinary morality is for ordinary people. -- Aleister Crowley