my %hash = ();
while (<FILE>)
{
s/\r|\n|//g;
s/#.*//;
#split the comma seperated values
($FirstCol,$SecondCol) = split(/\,/) ;
$hash{$FirstCol}{$SecondCol}++;
}
Close FILE;
# the next loop prints the keys/values of the hash
foreach $FirstCol (keys %hash)
{
print "Key: $FirstCol, Value: $hash{$FirstCol}\n";
}
print "\n";
==========================================
Output:
Key: abc, Value: HASH(0x9cb5eb8)
Key: xyz, Value: HASH(0x9cb5e94)
It does not print abc-1,abc-2,abc-3 or xyz-1,xyz-2,xyz-3.