Well, I'm just taking a guess as to what you want from the data you have supplied, but a hash of hashes might work
my %people = ( 7 => { name => 'Bob Jones', address => '555 Anywhere Street', city => 'Allentown', state => 'Pennsylvania' }, 3 => { name => 'Pete Hollister', address => '222 Northview Drive', city => 'Shoreham', state => 'unknown' } ); my $idnumber = 3; print $people{ $idnumber }{ name };
The above code prints "Pete Hollister". Here's the same thing with a hash of arrays:
my %people = ( 7 => [ 'Bob Jones', '555 Anywhere Street', 'Allentown', + 'Pennsylvania' ], 3 => [ 'Pete Hollister', '222 Northview Drive', 'Shoreh +am', 'unknown' ] ); my $idnumber = 3; print $people{ $idnumber }[0];
Or, to be complete obnoxious (and I don't recommend this), we could go with an array of pseudo-hashes which would allow you to use this as a hash of hashes or a hash of arrays as you like:
my $phashref = { name => 1, address => 2, city => 3, state => 4 }; my %people = ( 7 =>[$phashref, 'Bob Jones', '555 Anywhere Street', 'Al +lentown', 'Pennsylvania' ], 3 =>[$phashref, 'Pete Hollister', '222 Northview Drive' +, 'Shoreham', 'unknown' ] ); my $idnumber = 3; print $people{ $idnumber }->{ name } . "\n"; print $people{ $idnumber }->[1];
The above resulted from my being a bit bored at work and having some free time. I was just playing around and I strongly advise against this approach. Aside from the difficulties with maintenance, merlyn mentioned that pseudo-hashes are probably not going to be in Perl 6.

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.


In reply to (Ovid) Re: Complex Data Structures? by Ovid
in thread Complex Data Structures? by Anonymous Monk

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.