McLogic,

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.



--chargrill
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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.