- publishing free software manuals
Perl Language Reference Manual
by Larry Wall and others
Paperback (6"x9"), 724 pages
ISBN 9781906966027
RRP £29.95 ($39.95)

Sales of this book support The Perl Foundation! Get a printed copy>>>

8.3.3 Localization of globs

The construct

local *name;

creates a whole new symbol table entry for the glob name in the current package. That means that all variables in its glob slot ($name, @name, %name, &name, and the name filehandle) are dynamically reset.

This implies, among other things, that any magic eventually carried by those variables is locally lost. In other words, saying local */ will not have any effect on the internal value of the input record separator.

Notably, if you want to work with a brand new value of the default scalar $_, and avoid the potential problem listed above about $_ previously carrying a magic value, you should use local *_ instead of local $_. As of perl 5.9.1, you can also use the lexical form of $_ (declaring it with my $_), which avoids completely this problem.

ISBN 9781906966027Perl Language Reference ManualSee the print edition