# Not using strict, for demonstration. sub at_top { print "Foo is: $foo\n"; } # This is the body of the script, where a head-to-tail flow is in effect my $foo = "I wanted this to be visible only for the body, not all of my subs!"; at_top(); # "Foo is: " at_bottom(); # "Foo is: I wanted ..." sub at_bottom { # We're in the same lexical scope!! print "Foo is: $foo\n"; } #### use strict; my $foo = "blah"; my $bar = "hello, world!"; sub mistake { print $foo; # Works, and prints blah }