Hell Monks,

Ok so I decided to face my fears and try to learn how to use hashes. It's not so much the data structure that worries me (I get how it flows), but the excess of curly/square brackets as well as parenthesis and how there organized, etc...

So I have this data structure below. It uses an array of data, and I assign that array to a hash using the [1] element as the key (which is the record/file ID). This is the assignment statement I use to achieve that.

my %records; #--> Hash to be used for the data my @owner_record; #--> Array holds the data to be placed into the hash $records{"$owner_record[1]"} = [ "$owner_record[5]", "$owner_record[0] +", "$owner_record[6]", "$owner_record[9]", (join ":", "$owner_record[ +10] $owner_record[11]"), []; ]; #This hash (%records) prints the following when I use the "Data::Dumpe +r". print Dumper \%records; __OUTPUT__ $VAR1 = { '999?AlphaMusic' => [ 'Bill', '/ud/NEW-PrOdUcTs/NWA', '5151515', '10:51:00', 'Sep 16', [] ], '667!NEWPRODUCT' => [ 'matthew', '/ud/QC-PROD/NWO', '5555555', '10:25:00', 'Sep 16', [] ], '001!SCHEDULE' => [ 'richard', '/ud/QC-DATA/CONTROL', '5005444', '10:50:44', 'Sep 16', [] ] };

So my question is, is it possible to assign the values within the "RECORD_ID" (RECORD_ID = '999?AlphaMusic', '667!NEWPRODUCT', '001!SCHEDULE') to keys of there own?

So for example, with the first element of the hash the structure would have keys as follows:
RECORD_ID => '999?AlphaMusic' [ USER => 'Bill', FILENAME => '/ud/NEW-PrOdUcTs/NWA', PID => '5151515', TIME => '10:51:00', DATE => 'Sep 16', ELAPSED => '', #--> Will be used la +ter ]


Any help would be great. And remember my experience level is pretty low so you may speak to me as if I were 2 years old, haha just kidding but you know what I mean.

Thanks in Advance,
Matt


.

In reply to Perl Hashes, keys under keys (I think)? by mmartin

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.