my $foo = "hello"; { # this affects the outer $foo $foo .= " world"; my $foo = "something else"; print "inner foo is $foo\n"; }; print "outer foo is $foo\n"; # produces inner foo is something else outer foo is hello world #### my $foo = "defined"; BEGIN { print "foo is ", defined($foo) ? $foo : 'undef', " during BEGIN phase\n"; }; print "foo is ", defined($foo) ? $foo : undef, " at runtime\n"; # produces foo is undef during BEGIN phase foo is defined at runtime