develooper Front page | perl.perl5.porters | Postings from January 2022

Re: Can't localize lexical variable $x at ...

Thread Previous | Thread Next
From:
yb
Date:
January 25, 2022 15:04
Subject:
Re: Can't localize lexical variable $x at ...
Message ID:
YfARawUuYnw0MLw1@rslinux.fun
On Tue, Jan 25, 2022 at 01:20:17PM +0000, hv@crypt.org wrote:
> I think of local() as "temporarily replace the value at this lvalue
> with a new value, restore it at the end of the current lexical scope".
> This is hugely useful in many situations that would otherwise require
> more and slower code with much more opportunity for error.

Out of curiosity, is there any reason not to simply shadow it: my $x = ...?

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About