local $variable = xpathlocal $variable [ $variable ... ]


This command acts in a very similar way as assign does, except that the variable assignment is done temporarily and lasts only for the rest of its enclosing command-or-block or subroutine. At the end of the enclosing block or subroutine, the original value is restored. This also reverts any later usual assignments to the variable done occurring before the end of the block. This command may also be used without the assignment part.

Note, that the variable itself remains global in the sense that it is still visible to any subroutine called subsequently from the same block. Unlike my declaration, it does not create a new lexically scoped variable.

Hint for Perl programmers: local in XSH2 works exactly as local in Perl.

See Also

assign, my, def