# ... $arrayref->[0] = 5; # ... { my $lcl = $arrayref->[0]; $arrayref->[0] = 0; # execute some code, which sees 0 not 5 $arrayref->[0] = $lcl; } # now array element is 5 again