in reply to Counting Hash values?
G'day packetstormer,
I'm unsure whether your input data is raw data as you've presented it:
5030 => 5030|RED DOOR|10-14 ...
or an actual hash (which you've called "Main Hash"); this would look different to how you've presented it:
5030 => '5030|RED DOOR|10-14', ...
If the former, the following code should do what you want. I have tested this but I'm not going to repost the input data and Dumper output: it's no different to what's been posted several times already.
my %extract; while (<>) { /\s(\d+)\|(.*)\Z/ && push @{$extract{$2}}, $1; }
[I acknowledge the similarity to the technique used by Kenosis. If your input is an actual hash; I'd recommend using that code.]
-- Ken
|
|---|