Musing on Mark Jason Dominus's Seven Useful Uses of local, I think I've come up with another one.

The most common use I have for local is with %ENV. The article doesn't specifically mention environment variables. There are instances where I am doing one of the following:

Thinking about it more, I would suggest that @ARGV belongs in the same category, as used in the file slurp idiom:

my $slurp = do { local (@ARGV, $/) = 'foo.txt'; <>};

There's also localising @ARGV for handling INCLUDE directives in the input stream.

These uses of local could be thought of as a special case of number 6 (Dynamic Scope Revisited), or possibly number 1 (Special Variables), but I think they are a new category.

Update:Looks like there might be a problem with plover.com - try this link as an alernative for MJD's article.

--

Oh Lord, won’t you burn me a Knoppix CD ?
My friends all rate Windows, I must disagree.
Your powers of persuasion will set them all free,
So oh Lord, won’t you burn me a Knoppix CD ?
(Missquoting Janis Joplin)


In reply to An eighth use of local by rinceWind

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":