my $ref; { my @array = 'element'; $ref = \@array; } # Because the array is lexically scoped (my), # the array would normally be freed here*, # but the reference is keeping it alive. print "$ref->[0]\n"; # Prints 'element' $ref = undef; # The scalar stops referencing the array, # so it's freed here. #### my @outer; for (1..2) { my @inner = "pass $_"; push @outer, \@inner; } print "@{ $outer[0] }\n"; # pass 1 print "@{ $outer[1] }\n"; # pass 2 #### for (1..10) { my $r1; my $r2 = \$r1; my $r3 = \$r2; $r1 = \$r3; } # You have just leaked 30 variables.