sub foo { local $foo = 1; if (1 == 1) { # just to demonstrate the point $foo++; } print "From foo: $foo\n"; bar(); } sub bar { # this variable will be set to whatever it was # before we got called print "From bar: $foo\n"; } $foo = 5; foo(); bar();