use vars qw( $x ); # a package global $x = 'outer'; # this block: { my $save_x = $x; # localize $x by saving its value $x = 'inner'; # change $x to hearts content some_sub( $x ); # some_sub() sees $x with value 'inner' $x = $save_x; # restore original value just before exiting block } # is functionally identical to this block: { local $x = 'inner'; some_sub( $x ); } # in both cases, some_sub() is called with the package global $x set # to 'inner' and in both cases, the value of $x is restored when the # block exits, except in the 'local' case, it is not necessary to # explicitly restore $x