foreach (1..5) { my $a; my $b; $a->{b} = $b; $b->{a} = $a; } # since both are pointing to each other they will never get collected.