{ # start of block of variables private to function foo() my @stack; sub foo { my ($var) = shift; push(@stack, $x); $x=$var; # code involving foo() and $x goes here... $x=pop(@stack); } # end foo } # end block of variables private to function foo()