=over

=item local EXPR
X<local>

You really probably want to be using L<C<my>|/my VARLIST> instead,
because L<C<local>|/local EXPR> isn't what most people think of as
"local".  See L<perlsub/"Private Variables via my()"> for details.

A local modifies the listed variables to be local to the enclosing
block, file, or eval.  If more than one value is listed, the list must
be placed in parentheses.  See L<perlsub/"Temporary Values via local()">
for details, including issues with tied arrays and hashes.

Like L<C<my>|/my VARLIST>, L<C<state>|/state VARLIST>, and
L<C<our>|/our VARLIST>, L<C<local>|/local EXPR> can operate on a variable
anywhere it appears in an expression (aside from interpolation in strings).
Unlike the other declarations, the effect of L<C<local>|/local EXPR> happens
at runtime, and so it will apply to additional uses of the same variable
executed after the declaration, even within the same statement. Note that
this does not include uses within an expression assigned to the variable
when it is localized, because the assigned expression is evaluated before
the localization.

    package main;
    our $x = 2;
    {
      foo($x, local $x = $x + 1, $x); # foo() receives (2, 3, 3)
      # $main::x is 3 within the call to foo()
    }
    foo($x); # foo() receives (2) and $main::x is 2

The C<delete local EXPR> construct can also be used to localize the deletion
of array/hash elements to the current block.
See L<perlsub/"Localized deletion of elements of composite types">.

=back