http://www.perlmonks.org?node_id=89879

acser has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks, Try the following code for  $HASH_SIZE = 5; and  $HASH_SIZE = 10; and  $HASH_SIZE = 100;. I cannot explain the results. Can anyone please help me understand this? I am trying to test equality of contents of two hash tables. Your help is greatly appreciated, Andras Attached testcase:
#!/usr/bin/perl $HASH_SIZE = 100; %hash1; %hash2; for ($i=0; $i < $HASH_SIZE; $i++) { $hash1{"$i"} = "i=$i"; } %hash2 = %hash1; print "\n\n%hash1\n"; foreach my $key (keys %hash1) { print "$key:$hash1{$key} "; } print "\n%hash2\n"; foreach my $key (keys %hash2) { print "$key:$hash2{$key} "; } if (%hash1 == %hash2) { print "\nequal\n"; } else { print "\nnon equal\n"; } $hash2{"anotherone"} = "anotherONE"; print "\n\n%hash1\n"; foreach my $key (keys %hash1) { print "$key:$hash1{$key} "; } print "\n%hash2\n"; foreach my $key (keys %hash2) { print "$key:$hash2{$key} "; } if (%hash1 == %hash2) { print "\nequal\n"; } else { print "\nnon equal\n"; } #End of testcase