I’d gladly appreciate some advice on this problem I am having with perl.
If I have an array and it contains for example the following integers:
1, 2, 3, 1, 1, 1, 1, 7, 1, 4, 1, 1, 1
once I have computed counts of keys using a hash, the key to value pairs will be:
1 => 9, 2 => 1, 3 => 1, 4 => 1, 7 => 1
I can assign both sets of numbers (keys and values) to different arrays to use them later, however if I now want an array which looks like this: (9, 1, 1, 1, 0, 0, 1) with the values in positions corresponding to the keys, with 0‘s for keys which did not appear in the list, namely 5 and 6, how would i code this in perl?
Thanks!
1 Answer