why_bird has asked for the wisdom of the Perl Monks concerning the following question:
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)
Those are my principles. If you don't like them I have others.
-- Groucho Marx
|Replies are listed 'Best First'.|
Re: Making a hash of arrays from a while loop
by moritz (Cardinal) on Mar 04, 2008 at 09:30 UTC