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):
1 -> @{a, b, c} 2 -> @{d, e, f} 3 -> @{g, h, i}
My first task i needed to do to this hash was print out each key, with each corresponding value on a new line, thus:
1, a 1, b ... 3, h 3, i
This was straightforward. My new requirement is to print in the form:
a, 1 b, 1 c, 1 ... g, 3 h, 3 i, 3
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
In reply to Reorganising a Hash for Output by arunhorne
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |