Copying a hash-of-hashes

From: Luke Bakken (Luke.Bakken_at_getronics.com)
Date: 12/30/04

  • Next message: Alfred Vahau: "Re: Copying a hash-of-hashes"
    Date: Thu, 30 Dec 2004 10:31:04 -0800
    To: <beginners@perl.org>
    
    

    > Hello List,
    > To explain the problem I am having, I wrote a simple snipet
    > that doesn't do
    > anything meaningful other than illustrating the behaviour I
    > want to avoid:
    >
    > my %hoh = (
    > 1 => {
    > a => 5, b => 5
    > },
    >
    > 2 => 5
    > );
    >
    >
    > my @res = &RANDOMSUB; #call a random subroutine
    >
    > print "$hoh{1}{a} $hoh{2} \n";
    >
    >
    > sub RANDOMSUB {
    > my %hohcopy = %hoh;
    >
    > $hohcopy{1}{a} = 2;
    > $hohcopy{2} = 2;
    > }

    Search for "clone" on search.cpan.org


  • Next message: Alfred Vahau: "Re: Copying a hash-of-hashes"