use strict; use warnings; sub run_this { shift->() } { my $x = "hello\n"; sub foo { # print $x; run_this(sub { print $x; }); } } foo();