you have a space that shouldn't be there:

>         print "THIS DOESN'T WORK: $key $newHash {$key}\n";
                                                 ^
should be:
         print "THIS DOESN'T WORK: $key $newHash{$key}\n";

> -----Original Message-----
> From: Simon Tomlinson [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 18, 2002 9:06 AM
> To: [EMAIL PROTECTED]
> Subject: Array of Hashes
> 
> 
> Hi
> 
> I want to put a hash into each element of an array.  I do it 
> like the following bit of code.  When I iterate round my hash 
> before putting it in the array of the hash values/keys are 
> there.  However, when I iterate through the hash after 
> putting it in the array all i get is '4/8' as the ouput.
> 
> I am sure this is very simple and I'm doing something stupid. 
>  Does anyone have any ideas?
> 
> Thanks in advance,
> Simon.
> 
> my @array
> my $count = 0;
> my $maxCount = 4;
> 
> while $count < $maxCount
> {
>     my %myHash = &getHash;
> 
>     foreach $key (keys %myHash )
>     {
>        print "THIS WORKS: $key $myHash{$key}\n";
>     }
> 
>     # Now assign the hash to my array
>     $array[$count] = %myHash;
> 
>     my %newHash = $array[$count];
>     foreach $key (keys %newHash )
>     {
>         print "THIS DOESN'T WORK: $key $newHash {$key}\n";
>     }
> }
> 
> 
> --
> 
> This e-mail may contain confidential and/or privileged 
> information. If you are not the intended recipient (or have 
> received this e-mail in error) please notify the sender 
> immediately and destroy this e-mail. Any unauthorized 
> copying, disclosure or distribution of the material in this 
> e-mail is strictly forbidden.
> 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

----------------------------------------------------------------------------
--------------------
The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to