Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Counting Hash values?

by denishowe (Acolyte)
on Mar 12, 2013 at 17:45 UTC ( #1023029=note: print w/replies, xml ) Need Help??


in reply to Counting Hash values?

Ignore the input keys, split each value on its first "|", collect all unique preceding numbers hashed by following string.
foreach (values %in) { /(.*?)\|(.*)/; $out{$2}{$1} = 1; }
Convert %out values from hash ref to array of keys
foreach (values %out) { $_ = [sort keys %$_]; } # $out{"RED DOOR|10-14"}[0] = 73 etc
I'm assuming there may be repeated values in the input but you only want each number once per key in the output.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1023029]
help
Chatterbox?
and the pool shimmers...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2018-06-19 03:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (111 votes). Check out past polls.

    Notices?