#!/local/bin/perl -w use warnings; use strict; # Runs the sub reference in arg #1 sub Doit { &{$_[0]}; } # Start of a big block - don't want to pollute { my $x = 777; my $y = 222; 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"; { Doit( sub { print "x = $x\n\n"; print " y = $y\n\n"; } ); } } } # Big Block mysub();