willdooUK has asked for the wisdom of the Perl Monks concerning the following question:
What I want is for the %new_attrs hash to be loaded with the hash that I put into %container, but it only wants to give me a garbage reference. If I try the line like this:my %attrs = ( name => 'Band', link => 'band.html'); print "ATTRS KEYS = ", keys %attrs, "\n"; print "ATTRS VALUES = ", values %attrs, "\n"; my %container = (); $container{ATTRIBUTES} = %attrs; print "CONTAINER KEYS = ", keys %container, "\n"; print "CONTAINER VALUES = ", values %container, "\n"; my %new_attrs = $container{ATTRIBUTES}; print "NEW_ATTRS KEYS = ", keys %new_attrs, "\n"; print "NEW_ATTRS VALUES = ", values %new_attrs, "\n";
... I get nothing out at the end (other than a Can't use string ("1/8") as a HASH ref while "strict refs" error if strict is in use).my %new_attrs = %{$container{ATTRIBUTES}};
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Dynamically building a hash of hashes
by japhy (Canon) on Jul 12, 2001 at 16:11 UTC | |
by willdooUK (Beadle) on Jul 12, 2001 at 16:14 UTC | |
by japhy (Canon) on Jul 12, 2001 at 16:20 UTC |