Re: Copying a Hash

2012-01-31 Thread Shawn H Corey
On 12-01-31 01:11 PM, Matt wrote: When I copy a hash like so: my %hash2 = %hash1; Modifying hash2 seems to modify hash1. How do I make it so there both independent after being copied? This creates a shallow copy. It does not copy the contents of any references in the hash. To do that, use

Copying a Hash

2012-01-31 Thread Matt
When I copy a hash like so: my %hash2 = %hash1; Modifying hash2 seems to modify hash1. How do I make it so there both independent after being copied? -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Copying a hash-of-hashes

2004-12-31 Thread Octavian Rasnita
What's the difference between using the Clone module and simply assigning $ref1 = $ref2? Thanks. Teddy - Original Message - From: "zentara" <[EMAIL PROTECTED]> To: Sent: Thursday, December 30, 2004 3:45 PM Subject: Re: Copying a hash-of-hashes On Wed, 29 De

Re: Copying a hash-of-hashes

2004-12-30 Thread Alfred Vahau
Hi, The three CPAN modules suitable for copying data structures are: Storable, Data::Dumper and FreezeThaw. Of these, Storable offers the dclone method which addresses the problem on hand. use Storable qw(dclone); $ref2 = dclone ($ref1); The method works on references to scalars, arrays and hashe

Copying a hash-of-hashes

2004-12-30 Thread Bakken, Luke
> 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 >

Re: Copying a hash-of-hashes

2004-12-30 Thread Dave Gray
> The question is whether there is an elegant way to produce a complete copy > of a hash-of-hashes-of-hashes-...-of-hashes for internal subroutine purposes > and make sure that all references will be translated properly as well, > leaving the subroutine no ability to modify the main hash. You migh

RE : Copying a hash-of-hashes

2004-12-30 Thread Jose Nyimi
> -Message d'origine- > De : Peter Rabbitson [mailto:[EMAIL PROTECTED] > Envoyé : jeudi 30 décembre 2004 04:58 > À : beginners@perl.org > Objet : Copying a hash-of-hashes > > Hello List, > To explain the problem I am having, I wrote a simple snipet

Copying a hash-of-hashes

2004-12-29 Thread Peter Rabbitson
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 = &RANDO