develooper Front page | perl.perl5.porters | Postings from August 2021

Re: `local` on lexicals

Thread Previous
From:
Felipe Gasper
Date:
August 9, 2021 14:24
Subject:
Re: `local` on lexicals
Message ID:
99933B8C-B6E4-4A9B-AF95-E47996471374@felipegasper.com

> On Aug 9, 2021, at 10:19 AM, Paul LeoNerd Evans <leonerd@leonerd.org.uk> wrote:
> 
> Perl currently does not permit this:
> 
>  $ perl -E 'my $x = 123; { local $x = 456; say $x }'
>  Can't localize lexical variable $x at -e line 1.

IMO it would be lovely if Perl allowed this, as that’s a likely point of confusion for newcomers. It confused me back-when, at least.

-FG
Thread Previous


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