#!/local/bin/perl -w use warnings; use strict; # Start of a big block - don't want to pollute { my $y = 222; my $x = 777; print "Initialized, what's the values?"; print " x = $x\n"; print " y = $y\n\n"; sub mysub { print " Start of subroutine\n"; print " what's x? (forget y for now)\n"; print " x = $x\n\n"; print " Going to child block\n"; print " let's inspect the variables again:\n"; my $sr = sub { print "y = $y\n\n"; print "x = $x\n\n"; }; &$sr; } } # Big Block mysub();