my %hash; my $key= 'aa'; my $count= @ARGV ? shift(@ARGV) : 20; $hash{$key}= 'base'; while( 1 ) { $hash{++$key}= 'test'; if( %hash =~ /^1/ ) { print "Collision: $key\n"; exit if --$count <= 0; } delete $hash{$key}; }