in reply to Help with hash/array data structure
So that gets you some of the way there as far as creating data and seeing what it is actually doing.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'
or if you wanted to get all the keys for the hash in the first element of the array you would use:$example[1]->{firstname};
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.my @first_elm_keys = keys %{$example[0]};
|
|---|