I want to get the number of entries for each group, but it seems to be giving me the wrong answer. There are elements in each group that might be repeated. The results I'm getting don't make sense. What am I doing wrong?
my %hash;
while(<>)
{
chomp($_);
if(/(\d+)\t(\d+)/)
{
my $group = $1;
my $element = $2;
$hash{$group}{$element}=1;
}
}
foreach my $curr(keys %hash)
{
my $numElementsInCurr = keys %{$hash{$curr}};
print "$curr\t$numElementsInCurr\n";
}