use strict; use warnings; my %UH; $UH{'k1'} = 1; # hash contains 1 item $UH('k2'} = 1; # hash contains 2 items $UH{'k1'} = 1; # at this point the hash still contains 2 items for my $k (sort keys %UH){ print "Hash contains key '$k'\n"; }