$ perl -e'
use feature qw( say );
say 0+\$x;
{ local $x; say 0+\$x; }
say 0+\$x;
'
94031376424552
94031376229560
94031376424552
####
$ perl -e'
use feature qw( say );
$x = 2;
say 0+\$x;
say $x;
sub {
local $x = 3;
say 0+\$x;
say $x;
say $_[0];
}->( $x );
say 0+\$x;
say $x;
'
94300947464040 Address of pre-local $x
2 Value of pre-local $x
94300947268840 Address of post-local $x
3 Value of post-local $x
2 Value of pre-local $x
94300947464040 $x is restored
2 Value of pre-local $x
####
$ perl -e'
use feature qw( say );
$! = 2;
say 0+\$!;
say 0+$!;
sub {
local $! = 3;
say 0+\$!;
say 0+$!;
say 0+$_[0];
}->( $! );
say 0+\$!;
say 0+$!;
'
93839899443048 Address of pre-local $!
2 Value of pre-local $! (aka value of errno)
93839899247848 Address of post-local $!
3 Value of post-local $! (aka value of errno)
3 Value of pre-local $! (aka value of errno)
93839899443048 $! is restored
3 Value of pre-local $! (aka value of errno)