#!/usr/bin/perl -w use strict; open FIN,"){ chomp $line; my @f=split(",",$line); unless (exists($buckets->{$f[1]}){ $buckets->{$f[1]} = { count => 0, where =>[ ] }; } if ( $f[4] > 0 ) { $buckets->{$f[1]}->{count}++; push @{$buckets->{$f[1]}},$f[0]; } } close FIN; foreach my $key (sort keys %$buckets){ next unless $buckets->{$key}->{count} > 0 ; printf "%s\t%d\t%s\n", $key,$buckets->{$key}->{count}, join(",",sort @{$buckets->{$key}->{where}}); } # ####################################################### done