M
mlwollman
Hello all,
I'm very, very new to Perl, and I have a question I can't quite find
the answer in the O'Reilly Perl books (Learning, Programming, and
Cookbook). Any assistance would be helpful.
I have a hash with key value pairs like:
1 => Chocolate,Vanilla,Rocky Road
2 => Strawberry,Vanilla, Pistachio
3 => Cookie Dough,Chocolate
4 => Strawberry,Pistachio
And I need to transform it to:
Chocolate => 1,3
Vanilla => 1,2
Rocky Road => 1
Strawberry => 2,4
Pistachio =>2,4
Cookie Dough => 3
What's a good, simple way to do that?
I thought about using while each and changing the value to an array and
foreach array element make a new has with the array element as a key
and the old key join() any existing values, I think. I'm pretty
confused now.
Thank You,
Matt
I'm very, very new to Perl, and I have a question I can't quite find
the answer in the O'Reilly Perl books (Learning, Programming, and
Cookbook). Any assistance would be helpful.
I have a hash with key value pairs like:
1 => Chocolate,Vanilla,Rocky Road
2 => Strawberry,Vanilla, Pistachio
3 => Cookie Dough,Chocolate
4 => Strawberry,Pistachio
And I need to transform it to:
Chocolate => 1,3
Vanilla => 1,2
Rocky Road => 1
Strawberry => 2,4
Pistachio =>2,4
Cookie Dough => 3
What's a good, simple way to do that?
I thought about using while each and changing the value to an array and
foreach array element make a new has with the array element as a key
and the old key join() any existing values, I think. I'm pretty
confused now.
Thank You,
Matt