in reply to Referencing to a hash inside a hash of hashes.
When you assign like $hash{'myhash'}->{ODIR} = %direc; .. there's 2 problems. One, it should be.. $hash->{'myhash'}{ODIR} = ... and second, it's not doing what you think it's doing.
Without giving it away, put this in your script.
That is exactly how the assignment is getting evaluated. It's not assigning the hash itself, it's assigning the results of the hash being evaluated in scalar context.print scalar %direc;
What I think you want to do is assign a refrence to the hash as in
Now the key ODIR will contain a refrence to the hash %direc. And you'd print it like so..$hash->{'myhash'}{ODIR} = \%direc;
Hope this helps..foreach (sort keys %{$hash->{myhash}{ODIR}}){ print "$_ => $hash->{myhash}{ODIR}{$_}\n"; }
|
---|