Maybe something like:

use warnings; use strict; use Data::Dumper; my %hash = map { chomp; split ' => ', $_ } <DATA>; my %out; for (values %hash) { my ($val, $key) = split /\|/, $_, 2; push @{$out{$key}}, $val; } print Dumper \%out; __DATA__ 5030 => 5030|RED DOOR|10-14 1049 => 1049|RED DOOR|10-14 4990 => 4990|RED DOOR|10-14 959 => 959|RED DOOR|10-14 15047 => 15047|FLOWER|13+ 5565 => 5565|RED DOOR|10-14 4449 => 4449|RED DOOR|10-14 1065 => 1065|RED DOOR|10-14 2992 => 2992|RED DOOR|10-14 4956 => 4956|RED DOOR|10-14 17665 => 17665|FLOWER|13+ 6217 => 6217|RED DOOR|10-14 1224 => 1224|RED DOOR|10-14 424 => 424|RED DOOR|10-14 368 => 368|RED DOOR|10-14 451 => 451|RED DOOR|10-14 7752 => 7752|RED DOOR|10-14 4070 => 4070|RED DOOR|10-14 1312 => 1312|RED DOOR|10-14 17668 => 17668|FLOWER|13+ 4224 => 4224|RED DOOR|10-14 3588 => 3588|RED DOOR|10-14 11076 => 11076|RED DOOR|10-14 2986 => 2986|RED DOOR|10-14 2402 => 2402|RED DOOR|10-14 10834 => 10834|RED DOOR|10-14 849 => 849|RED DOOR|10-14 2954 => 2954|RED DOOR|10-14 11 => 11|RED DOOR|10-14 4093 => 4093|RED DOOR|10-14 492 => 492|RED DOOR|10-14 1861 => 1861|RED DOOR|10-14 4384 => 4384|RED DOOR|10-14 15037 => 15037|FLOWER|11+ 13044 => 13044|FLOWER|13+ 899 => 899|RED DOOR|10-14 292 => 292|RED DOOR|10-14 10421 => 10421|RED DOOR|10-14 4120 => 4120|RED DOOR|10-14 5557 => 5557|RED DOOR|10-14 3859 => 3859|RED DOOR|10-14 930 => 930|RED DOOR|10-14 649 => 649|RED DOOR|10-14 7511 => 7511|RED DOOR|10-14 648 => 648|RED DOOR|10-14 73 => 73|RED DOOR|10-14 12537 => 12537|RED DOOR|10-14 2485 => 2485|RED DOOR|10-14

In reply to Re: Counting Hash values? by thundergnat
in thread Counting Hash values? by packetstormer

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.