![]() |
|
Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Reorganising a Hash for Outputby arunhorne (Pilgrim) |
on May 07, 2002 at 13:06 UTC ( #164621=perlquestion: print w/replies, xml ) | Need Help?? |
arunhorne has asked for the wisdom of the Perl Monks concerning the following question: Hi all, I have a hash in the following format (the notation is my own brand ;) but what it shows is a scalar on the left mapping to an array of values (the right hand side is of course a ref to the actual array):
My first task i needed to do to this hash was print out each key, with each corresponding value on a new line, thus:
This was straightforward. My new requirement is to print in the form:
As an extra caveat I also want to make sure the output is ordered by the output, i.e. as it is in the above, a before b etc. Has anyone got any nice perl ways of doing this or am I going to have to go for brute force set of nested foreach statements? I certainly have no idea as to making the output ordered! By the way I still need to maintain the hash in its original form as the first output method (the one I have working) is still required. Thanks, Arun
Back to
Seekers of Perl Wisdom
|
|