my $c; my %s; sub foo { my ($x) = @_;; $c++; $s{\$x}++; foo($x-1) if $x; } for (1..1000) { foo(int(rand(6))+1); } print("foo() was called $c times, but only ", scalar(keys(%s)), " sets of lexicals were created.\n");