I've shortened your example and tidied it up a bit (and made it fit in the standard PM node code width) and made a few changes. First, the code:
#!/usr/bin/perl use strict; use warnings; my %member_info = ( mid => undef, created_info => { created_by => undef, created_date => undef, }, modified_info => { modified_by => undef, modified_date => undef, }, person => { salutation => undef, first_name => undef, middle_initial => undef, }, school => [ { school_type => "school", school_name => undef, graduation_date => undef }, { school_type => "school1", school_name => undef, graduation_date => undef }, ], ); $member_info{'person'}{'salutation'} = "test"; $member_info{'school'}[0]{'school_type'} = "testing"; $member_info{'school'}[1]{'school_type'} = "testing2"; use Data::Dumper; print Dumper \%member_info; OUTPUT: $VAR1 = { 'mid' => undef, 'modified_info' => { 'modified_date' => undef, 'modified_by' => undef }, 'created_info' => { 'created_date' => undef, 'created_by' => undef }, 'person' => { 'middle_initial' => undef, 'salutation' => 'test', 'first_name' => undef }, 'school' => [ { 'graduation_date' => undef, 'school_name' => undef, 'school_type' => 'testing' }, { 'graduation_date' => undef, 'school_name' => undef, 'school_type' => 'testing2' } ] };
So as you can see, I'm able to set values for your HoAoH and/or HoH's.
Alternatively, you could do something like:
... school => { 0 => { school_type => undef }, 1 => { ... } }, ...
But then you'd have to access it via: $member_info{'school'}{0}{'school_type'}. But that seems less clear and more muddled than you'd probably want, and won't keep your schools in order as the array would.
s**lil*; $*=join'',sort split q**; s;.*;grr; &&s+(.(.)).+$2$1+; $; = qq-$_-;s,.*,ahc,;$,.=chop for split q,,,reverse;print for($,,$;,$*,$/)
In reply to Re: Mistake in data structure use?
by chargrill
in thread Mistake in data structure use?
by McLogic
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |