Perl was originally designed to carry on regardless, and that remains its blessing and curse, a bit like JavaScript which came later.
Unlike JavaScript, if you really want it to throw a warning or even bail out completely at compiling such constructs (at least some of the time, like this one) it’s pretty easy to turn that on rather than resort to an entirely different language.
use warnings; at the top of a program and it will punt a warning to STDERR as it carries merrily along.
Make that use warningsFATAL=> "syntax"; and things that are technically valid but semantically weird like this will throw the error early and also prevent the program from running in the first place.
it’s the string coercion that I have a problem with. I’d much rather have an error than have things silently be coerced to different types.
Perl was originally designed to carry on regardless, and that remains its blessing and curse, a bit like JavaScript which came later.
Unlike JavaScript, if you really want it to throw a warning or even bail out completely at compiling such constructs (at least some of the time, like this one) it’s pretty easy to turn that on rather than resort to an entirely different language.
use warnings;
at the top of a program and it will punt a warning to STDERR as it carries merrily along.Make that
use warnings FATAL => "syntax";
and things that are technically valid but semantically weird like this will throw the error early and also prevent the program from running in the first place.