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