in reply to Syntax for Hashes of Hashes
Hi,
my %g = (); while(<INFO>) { my ($name,$specie,$gender,$age,$hairColor) = split /,/,$_; $g{$name} = { SPECIE => $specie, GENDER => $gender, AGE => $age, HAIRCOLOR => $hairColor, }; }
To pass the inner hash as a reference to a subroutine you can simply say:
call_sub( $g{$name} );
That's because the value of the hash key is actually a reference to a hash.
But in this case I wouldn't use the $name as the key, because that way you can't have 2 people with the same name... Better to use a unique field, or an id number...
And then other interesting things like OO and DB... ;-)
Regards,
I like merlyn's disclaimer
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Syntax for Hashes of Hashes
by o2bwise (Scribe) on Jul 24, 2005 at 19:26 UTC | |
by hubb0r (Pilgrim) on Jul 24, 2005 at 19:53 UTC | |
by pg (Canon) on Jul 24, 2005 at 21:14 UTC | |
by planetscape (Chancellor) on Jul 25, 2005 at 05:29 UTC | |
by o2bwise (Scribe) on Jul 24, 2005 at 21:11 UTC | |
by hubb0r (Pilgrim) on Jul 25, 2005 at 01:48 UTC | |
by o2bwise (Scribe) on Jul 25, 2005 at 16:55 UTC | |
by pg (Canon) on Jul 24, 2005 at 21:10 UTC |