On Dec 25, 2003, at 7:02 AM, [EMAIL PROTECTED] wrote:

I'm working on a clone method for an object (which makes a deep copy of the data structure and all other data structures 'contained' by it).

The standard module Storable will do a deep copy for you with one subroutine call. Might want to check that out.


I'm trying to create a new reference that refers to the same thing an existing reference points to, but is actually a separate reference, so that you get two separately-valued references pointing to the same underlying value.

It's not going as planned.

Here's the code which I expected to work, but doesn't. I'm expecting \$$orig to result in a new reference, but instead it's reusing the original reference that I started with.

So:

    $s = "some string";
    $orig = \$s;
    $new = \$$orig;

I believe you just want:


$new = $orig;

You're trying to copy the reference and = generally means copy.

print "orig:$orig, new:$new\n";

James



-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to