my $test1 = 1; { my $test2 = 2; print " Inside: test1 = [$test1] test2 = [$test2]\n"; } print "Outside: test1 = [$test1] test2 = [$test2]\n"; #### D:\PerlMonks>scope1-fail.pl Inside: test1 = [1] test2 = [2] Outside: test1 = [1] test2 = [] D:\PerlMonks> #### <--- $test2 is blank! #### use strict; my $test1 = 1; { my $test2 = 2; print " Inside: test1 = [$test1] test2 = [$test2]\n"; } print "Outside: test1 = [$test1] test2 = [$test2]\n"; #### D:\PerlMonks>scope2-fail.pl Global symbol "$test2" requires explicit package name at D:\PerlMonks\scope2-fail.pl line 8. Execution of D:\PerlMonks\scope2-fail.pl aborted due to compilation errors. D:\PerlMonks> #### use strict; my $test1 = 1; my $test2; { my $test2 = 2; print " Inside: test1 = [$test1] test2 = [$test2]\n"; } print "Outside: test1 = [$test1] test2 = [$test2]\n"; #### D:\PerlMonks>scope3-fail.pl Inside: test1 = [1] test2 = [2] Outside: test1 = [1] test2 = [] D:\PerlMonks> #### <--- $test2 is still blank! #### use strict; use warnings; my $test1 = 1; my $test2; { my $test2 = 2; print " Inside: test1 = [$test1] test2 = [$test2]\n"; } print "Outside: test1 = [$test1] test2 = [$test2]\n"; #### D:\PerlMonks>scope4-fail.pl Inside: test1 = [1] test2 = [2] Use of uninitialized value $test2 in concatenation (.) or string at D:\PerlMonks\scope4-fail.pl line 10. Outside: test1 = [1] test2 = [] D:\PerlMonks> #### use strict; use warnings; my $test1 = 1; my $test2; { $test2 = 2; print " Inside: test1 = [$test1] test2 = [$test2]\n"; } print "Outside: test1 = [$test1] test2 = [$test2]\n"; exit; __END__ #### D:\PerlMonks>scope5-win.pl Inside: test1 = [1] test2 = [2] Outside: test1 = [1] test2 = [2] D:\PerlMonks>