More Hash problems

Jason White jasona at inetarena.com
Wed Jun 5 15:39:36 CDT 2002


I'm having some trouble with the contents of my hash changing.
I start with a numerically keyed list of arrays.  The first element of each array is a name.
The goal is to have one hash of rules indexable by integer keys and another indexable by name.

Here is my code:
my (%rules) = blah blah blah;  #Works and indexes fine
while(($key,$value)=each(%rules)){
    ($key,@{$value})=@{$value};
    $RULES{$key}=$value;
}

Now %RULES Works and indexes fine with the names as keys but the first element of my arrays are gone in the first hash.
I also tried adding %TmpHash=%rules and then parsing the %TmpHash, but it still affected %rules.
When I say $a=$b am I just setting a pointer? How can I actually copy the values?

is ($key,$value)=each(%rules) effectivly popping my first element?
should I switch to a foreach keys syntax?


Jason White
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/archives/pdx-pm-list/attachments/20020605/41328d09/attachment.htm


More information about the Pdx-pm-list mailing list