Hi folks, I've been having trouble referencing an array to the value pair of a hash.
The data that I have kind of looks like this:

ab mock 01 data1 data2 data3 data4
ab mock 02 data5 data6 data7 data8
ab mock 03 data9 data0 data3 data2

The third item (from the left) on each line is to be my key for the hash. But then as the value for the hash I want all the values on the line to be associated with that key. I've tried to split each element on the line into and array and then incorrectly tried to associate that with the hash but obviously that doesn't seem to be working and I don't know how to do it right :). Any help would be appreciated! Another question I would also have is how would I then get a particular array element for a particular key of the hash? Thanks.
here is part of the code:

open(PARMFILE, "<$parmfile") || die "unsuccessful open of input file $ +parmfile"; while (<PARMFILE>) { next if /^#/ || /^\s*$/; chomp; @temp=split(/\s+/,$_); $array_ref = \@temp; # confusion $dbparms{$temp[2]} = $array_ref; # here } close PARMFILE; foreach $item (sort keys %dbparms) { print "$item => $dbparms{$item} \n"; }

In reply to associate that array with this hash? by shaezi

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.