use strict; use warnings; sub outer { my ($x) = @_; local *inner = sub { print("$x\n"); }; inner(); } outer(4); outer(5); inner();