o2bwise has asked for the wisdom of the Perl Monks concerning the following question:
and here is the code I presently have (I know it's silly, but I am passing everything by reference):Tony,human,male,47,gray Mark,human,male,48,brown Tyler,dog,male,11,brown Anthi,human,female,39,black Spud,cat,male,14,white Erica,human,female,23,blonde
One other thing I was wondering. In my application at my former place of employment, I had many records for the same inner hash. So, I did not create that inner hash until I first checked to see if it already was created. Might you also supply the syntax for this conditional?#!/usr/bin/perl -w use strict; my %myOuterHash = (); open (INFO,"<info.txt"); while (<INFO>) { my ($name,$species,$gender,$age,$hairColor) = split /,/,$_; %$myOuterHash{ $name } = (); addValues( \%$myOuterHash{ $name },\$species,\$gender,\$age,\$hair +Color); } sub addValues { my ( $hashNameRef,$speRef,$genRef,$ageRef,$hairColRef ) = @_; $$hashNameRef{ 'species' } = $$speRef; print "IN SUB:\t$$hashNameRef{ 'species' }\n"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Syntax for Hashes of Hashes
by fmerges (Chaplain) on Jul 24, 2005 at 18:42 UTC | |
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 pg (Canon) on Jul 24, 2005 at 21:10 UTC | |
Re: Syntax for Hashes of Hashes
by davidrw (Prior) on Jul 24, 2005 at 20:13 UTC |