$foo = 'foo'; sub printfoo { print $foo; } printfoo(); # prints 'foo' { local $foo = 'bar'; printfoo(); # prints 'bar' } printfoo(); # prints 'foo'