Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (2)
As of 2023-09-23 16:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?