On Nov 4, Frank Bax said:

$aSuit{0}{'a'} = 'A';
$aSuit{0}{'b'} = 'B';
$aSuit{0}{'c'} = 'C';
$aSuit{1}{'a'} = 'D';
$aSuit{1}{'b'} = 'E';
$aSuit{1}{'c'} = 'F';

Now I want to make $aSuit{1} a copy of $aSuit{0}
        %aSuit{1} = %aSuit{0};

Well, $aSuit{1} = $aSuit{0} would make $aSuit{1} and $aSuit{0} IDENTICAL. Meaning, when $aSuit{0}{a}, $aSuit{1}{a} changes too. If you don't want that, you can do:

  %{ $aSuit{1} } = %{ $aSuit{0} };

But that only works one level deep. For generic copying of data structures, see the Storable module (comes with Perl):

  use Storable;
  $aSuit{1} = dclone($aSuit{0});

--
Jeff "japhy" Pinyan        %  How can we ever be the sold short or
RPI Acacia Brother #734    %  the cheated, we who for every service
http://www.perlmonks.org/  %  have long ago been overpaid?
http://princeton.pm.org/   %    -- Meister Eckhart

--
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