hi, need help on hashes here is the code :
print "Enter the words: "; chomp(my @words = <STDIN>); my %names; foreach $a (@words) { if (!%names) { print "hi\n"; $names{$a} = 1; } else { while ( ($key, $value) = each %names ) { if ($a eq $key) { $names{$key} += 1; } else { $names{$a} = 1; } } } } foreach ( ($key2, $value2) = each %names ) { print "$key2 => $value2\n"; } if i enter the values like a b a (separated by enter) then output is : hi a => 1 a => 1 instead it shud be : a => 1 b => 1 a =>2 please suggest regards