Good morning monks,

What I want to do is create a hash of arrays. The problem is that I want to do it by iterating through a while loop. The loop calculates the value of a variable $variable and an array @array. Each time the loop executes, I want to add the $variable as a key in my hash pointing to @array. I think it's the case that you have to pass arrays to hashes as references, so I'm having difficulty storing the value of the array (actually I'm also having trouble storing separate values for the key too, and I don't know why) rather than just getting the last key-value pair from the loop as my whole hash each time I run the program. Does that make sense? Any ideas? I was thinking about making an anonymous array from the values in @array, but don't know how to do that for an array that already exists.. I know this isn't a very well forumlated question, but please help if you can! (p.s. I don't know how many times the loop is going to execute)
Thanks :)

........
Those are my principles. If you don't like them I have others.
-- Groucho Marx
.......

In reply to Making a hash of arrays from a while loop by why_bird

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.