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

Re: perl -we '$00' dies in 5.32

Thread Previous | Thread Next
From:
Walt Mankowski
Date:
July 24, 2022 14:34
Subject:
Re: perl -we '$00' dies in 5.32
Message ID:
Yt1YYU83MRFP2c9A@mawode.com
On Fri, Jul 22, 2022 at 01:23:04PM +0000, Konovalov, Vadim via perl5-porters wrote:
> My scripts suddenly stopped working in newer perl because they use $00 variable.
> 
> $ perl -we '$00'
> Numeric variables with more than one digit may not start with '0' at -e line 1.

I'm confused by why you ever thought this would work. perlvar clearly
says

    Variable names in Perl can have several formats. Usually, they must
    begin with a letter or underscore ...

    Perl variable names may also be a sequence of digits, a single
    punctuation character, or the two-character sequence: "^" (caret or
    CIRCUMFLEX ACCENT) followed by any one of the characters "[][A-Z^_?\]".
    These names are all reserved for special uses by Perl; for example, the
    all-digits names are used to hold data captured by backreferences after
    a regular expression match.

git blame says that section was last modified in 2015, but there is
similar language saying that identifiers need to start with a letter
or underscore in perldata in perl 5.004, which dates back to 1997.

> This works well in 5.26.0
> 
> What this behaviour degrade was for?

It seems to me the change that broke your scripts was actually fixing
a bug that was allowing illegal variable names that are reserved by
Perl for regex backreferences.

Walt

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