Alistair, What you say makes sense to me but, I have been doing a similar thing. The difference is I would read in a hash table %Original_Hash and then rename ( Richard's way ) to say %Alpha, then I would read in another with the same name %Original_Hash and rename that one to %Gamma. Here is the problem the amount of memory allocated is very close to being 3 times the size of the hash tables. even if I undef %Original_Hash twice. I thought that the system was overwriting the first but would not release the second. I plan to change the way I get the Hash table into the system but I believe that the memory allocation problem will still be there. any Idea how to reclaim I.E. the Hash table are 50+ meg, if they were small I would not be concerned.
Later, Matt -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 13, 2003 7:52 AM To: Richard Beckett Cc: [EMAIL PROTECTED] Subject: RE: How does my default get undefined? Richard, > %hash_default = %hash; This does not copy the arrays or hashes referenced in the values of the hash. Remember a hash is an associative list of scalars. %hash = ($key1, $value1); So if you say: %hash_default = %hash; %hash_default is now equal ($key1, $value1); If $value1 happens to be a reference to an object then both hashes' values now point to the *same* object. For example: $hash{fred}{barney}=1; # %hash is ("fred",Ref to anon hash ("barney",1)); %hash_default = %hash; # copy %hash $hash_default{fred}{barney}++; # increment the anonymous hash's value print $hash{fred}{barney} # prints 2; For your particular example with a data structure two levels deep you'll need to loop over all of the keys of the first level; for my $key, (keys %hash) { %{$hash_default2{$key}} = %{$hash{$key}} } If you have a more complicated data structure. You'll need a more complicated loop. See the FAQ on copying data structures: D:\>perldoc -q copy Found in D:\perl\lib\pod\perlfaq4.pod How do I print out or copy a recursive data structure? <snip> See also: perlref.html and perlreftut.html HTH Alistair ----------------------------------------------------------------------- Registered Office: Marks & Spencer p.l.c Michael House, Baker Street, London, W1U 8EP Registered No. 214436 in England and Wales. Telephone (020) 7935 4422 Facsimile (020) 7487 2670 www.marksandspencer.com Please note that electronic mail may be monitored. This e-mail is confidential. If you received it by mistake, please let us know and then delete it from your system; you should not copy, disclose, or distribute its contents to anyone nor act in reliance on this e-mail, as this is prohibited and may be unlawful. The registered office of Marks and Spencer Financial Services PLC, Marks and Spencer Unit Trust Management Limited, Marks and Spencer Life Assurance Limited and Marks and Spencer Savings and Investments Limited is Kings Meadow, Chester, CH99 9FB. _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs