in reply to Re: Hashes, keys and multiple histogram
in thread Hashes, keys and multiple histogram
originally looked like this:%hist1 = map { $_ => 0 } @element;
The quoted output was also very different.$hist1{@element}++;
That's not very fair to people who spent some of their free time trying to help you, f77coder. :-(
Update: You are fairly new on this forum (13 writups), so I assume you did not realize that doing this kind of editing without stating it clearly is strongly discouraged around here. Because you are new, I'll consider these changes to your OP as just a small mistake, no big deal for me, I'll forget it.
And BTW, your current code:
may look superficially closer than the original code to what you want to obtain, but you are still quite not there. What happens with this map syntax is that, each time you encounter the same individual element, you override your previous hash having the same key with the new one, so that, at the end, the best you get is a unique list of values (the keys of the hash), but no information about their frequency for each hash.%hist1 = map { $_ => 0 } @element;
Assuming I understood what you want, the right solution is very probably the for loop with incrementation that I offered.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Hashes, keys and multiple histogram
by f77coder (Beadle) on Aug 18, 2014 at 01:35 UTC | |
by Laurent_R (Canon) on Aug 18, 2014 at 07:08 UTC | |
by f77coder (Beadle) on Aug 19, 2014 at 15:49 UTC |