use strict; my %TEMPS; my $max = 1_000_000; Foo->new() for (0..$max - 1); print "ok\n" if $max == scalar keys %TEMPS; package Foo; sub new { my $self = {}; $TEMPS{ $self->{ID} = "$self" } = $self; return $self; }