This may be an oversimplification, but here is one idea:
#!/usr/bin/perl -w
use strict;
open FIN,"<dataset.dat" or die "dataset.dat:$!";
my $buckets={};
while(my $line=<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
Caveat: not tested.. do not use for the control of a nuclear missile launch system.
Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg