in reply to Help with hash/array data structure

Greetings all,
Nested data structures will most definitely make you life easier... I suggest getting the book Advanced Perl Programming and reading the chapter on complex data structures. Also have a look at this node for a nutshell version of nested data types.
All that being said the one helpful (hopefully) piece of advice I would give you in working with this area of perl is, Always check your data. Personally I use Dumpvalue others around here tout Data::Dumper, the choice is yours.
Here is how I check my stuff.
use strict; #Always use Dumpvalue; ###just an example of nested data my @example = ( {'firstname'=>'Justin', 'lastname'=>'Tyme', 'Age'=>'21'}, {'firstname'=>'Ima', 'lastname'=>'Geek','Age'=>'21'} ); dump_ref(\@example);###you need to pass a reference to your data since + the dumpValues method only takes references. sub dump_ref { my $ref = shift; my $dumper = new Dumpvalue; $dumper->dumpValues($ref); } ___OUTPUT___ 0 ARRAY(0x80628f0) 0 HASH(0x804c8d4) 'Age' => 21 'firstname' => 'Justin' 'lastname' => 'Tyme' 1 HASH(0x80628b4) 'Age' => 21 'firstname' => 'Ima' 'lastname' => 'Geek'
So that gets you some of the way there as far as creating data and seeing what it is actually doing.
Now getting it back out! This is where I got the most tripped up. Just keep in mind that you must reference (or dereference in this case) the data in the form you will eventually be useing it.
So, if you want to get the firstname of the person in the second element of the array above it would be:
$example[1]->{firstname};
or if you wanted to get all the keys for the hash in the first element of the array you would use:
my @first_elm_keys = keys %{$example[0]};
Of course like with anything in perl there is more than one way to do it. I personally like the arrow dereferencing scheme. It just makes more sense to me, looks like its pointing to the data.
Hope that helps
-injunjoel