YPA124 NV
YPA124 NV
YPA124 V
YAR198 V
YAR198 V
YOB911 V
YOB911 V
YOB911 NV
YOB911 NA
So what i want to do is find out how many times each name on column 1 is represented by indicators on column 2.
So the output would look like this (column 1 would be the name, 2 would be the indicator and 3 would be how many times that indicator comes up per name):
YPA124 NV 2
YPA124 V 1
YAR198 V 2
YOB911 V 2
YOB911 NV 1
YOB911 NA 1
obviously I do not know how to do this so any help would be gladly appreciated.
while(<DATA>){
chomp;
my @tmp = split;
$hash{$tmp[0]}->{$tmp[1]}++;
$hash{$tmp[0]}->{_SEQ_}=$.
}
foreach my $key(sort {$hash{$a}->{_SEQ_} <=> $hash{$b}->{_SEQ_}} keys %hash){
my %tmp = %{$hash{$key}};
foreach my $k( grep {$_ ne "_SEQ_"} keys %tmp){
print $key," ",$k," ",$tmp{$k},"\n";
}
}
__DATA__
YPA124 NV
YPA124 NV
YPA124 V
YAR198 V
YAR198 V
YOB911 V
YOB911 V
YOB911 NV
YOB911 NA