develooper Front page | perl.perl5.porters | Postings from May 2023

Make => on assignment a syntax error?

Thread Next
May 17, 2023 12:50
Make => on assignment a syntax error?
Message ID:
Hi all,

Someone recently complained about trying to debug something like this[1]:

    $ perl -Mstrict -Mwarnings -E 'my $foo => 42; say $foo;'
    Useless use of a constant (42) in void context at -e line 1.
    Use of uninitialized value $foo in say at -e line 1.

If you're working with a codebase that doesn't have warnings, you won't
even get those warnings. You'll just get a silent, and very hard to track
down error.

When you're both declaring a variable and assigning to it, can we make
using => instead of = a syntax error? I've been bitten by this a few times
and the Useless use of a constant warning can get lost in a sea of stack



Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About