Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://956341]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2017-04-23 06:13 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (430 votes). Check out past polls.