sub foo { print " \$x is: $x\n"; } $x = "original state"; { # beginning of lexical scope local $x = "altered state"; foo(); } # end of lexical scope print "\$x is: $x\n"; __output__ $x is: altered state $x is: original state