use strict; use warnings; use Data::Dumper; my %hash; while() { my ($player,$tableid) = split; if (exists $hash{$tableid}) { push ($hash{$tableid},$player); } else { $hash{$tableid} = [$player]; } } print Dumper \%hash; while(my($tableid,$player) = each(%hash)) { print "\n\nTableid:$tableid\n"; print "\nPlayer:".join("\n",@{$player}); print "\nTotal:". scalar @{$player}; } __DATA__ kapp2cape1111 224 kapp2cape1113 224 kapp2cape1112 224 kapp2cape1111 225 kapp2cape1113 225 kapp2cape1112 225