in reply to Re: Re: Re: Re: OO - problem with inheritance
in thread OO - problem with inheritance

by copying the hash

Note that just copying the hash doesn't work for data structure you have used. Values of hash are hashrefs themselves so new copy will reuse parts of copied data structure. Thus changes in copy of data structure affect original data structure.

--
Ilya Martynov (http://martynov.org/)

  • Comment on Re: Re: Re: Re: Re: OO - problem with inheritance

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Re: OO - problem with inheritance
by uwevoelker (Pilgrim) on Jan 14, 2002 at 22:14 UTC
    Yes, I know. I have to iterate over each hash and make copies. A simple $ref1 = $ref is not enough.
    Thanks.
      When I want to do deep cloning I just use dclone from Storable. Works for data structures of any complexity. There is also exist module Clone.

      --
      Ilya Martynov (http://martynov.org/)

        I will use Clone.pm - it says it is faster than dclone. I do not need the hooks from Storable.
        Thank you for this hint, it saves me some time.