local doesn't create variables. It just backs up the value of the variable and restores it later.
I know *. Certainly there's an internal difference; but it seems to me that the casual user is not likely to encounter much difference between
our $x;
CODE INVOLVING OUTER $x
{
local $x;
CODE INVOLVING INNER $x
}
and
my $x;
CODE INVOLVING OUTER $x
{
my $x;
CODE INVOLVING INNER $x
}
That's by no means to say that there is no difference—indeed,
our $x; my $y;
sub twiddle { $x = $y = 'twiddled' }
{
local $x = 'local?';
my $y = 'local!';
twiddle;
say $x, ', ', $y;
}
shows that there is—just that one's not likely to see it in casual use.
* Ah, but re-reading shows that I didn't seem to understand: I said something about having two variables with the same name, when really the localised $x is the same variable as the original one, just with a ‘temporary’ value. Is that misstatement on my part what you were correcting?