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

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

Thread Previous | Thread Next
From:
Bram
Date:
July 23, 2022 13:50
Subject:
Re: perl -we '$00' dies in 5.32
Message ID:
62DBFC9F.3060104@perl.wizbit.be
On 22/07/2022 15:28, Marco Fontani 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.
>
> You can try wrapping them in ${} and they'll work again, i.e.:
>
> $ docker run -it --rm perl:5.36 perl -E'$00="foo";say"$00"'
> Numeric variables with more than one digit may not start with '0' at
> -e line 1.
>
> $ docker run -it --rm perl:5.36 perl -E'${00}="foo";say"${00}"'
> foo
>
> The ${00} syntax also works in previous Perls, from what I can tell.
>
Looking at commit message of 60267e1d0e12bb5bdc88c62a18294336ab03d4b8
and looking at the code:
That this works looks accidental and an off-by-one error...

    $ ./perl -e '${0};'
    $ ./perl -e '${00};'
    $ ./perl -e '${000};'
    Numeric variables with more than one digit may not start with '0' at
    -e line 1.

The entry added in perldiag (in commit
60267e1d0e12bb5bdc88c62a18294336ab03d4b8):

    The only numeric variable which is allowed to start with a 0 is C<$0>,
    and you mentioned a variable that starts with 0 that has more than one
    digit. (...)

Based on that I would say that the intention was to also disallow `${00}`.

(I'll submit a bug report for this in a bit)


Best regards,

Bram


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