Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Sorting a hash value that is a list

by tangent (Priest)
on Feb 26, 2012 at 23:45 UTC ( #956341=note: print w/ replies, xml ) Need Help??

in reply to Sorting a hash value that is a list

[interesting username]
You could create a hash to keep track of your users like so:
my %seen = (); while(<FILE>) { chomp; ($host, $grp, $gid, $userid) = split(/:/, $_); $group = "$grp:$gid"; # check to see if we've seen this group/user already next if $seen{$group}{$userid}++; push @{$table{$group}}, $userid; } Prints: group1:9001:user1,user2,user3,user4,user5 group1:9006: group2:9002:user1,user2,user3 group3:9003:user1,user2,user4 group4:9004:user1,user2,user5 group5:9005:user1,user2 group6:9006: 7
Note that $seen{$group}{$userid}++ only increments after the check
Comment on Re: Sorting a hash value that is a list
Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://956341]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2016-05-01 06:56 GMT
Find Nodes?
    Voting Booth?

    No recent polls found