News for hackers. Stuff that matters.
Re:PHP 8 by xorcist on Thursday November 26, 2020 @04:42PM (#25223734)
Perl avoids this problem by having contexts, a bit like casts but with easier syntax, and by having separate numeric and string equality operators.
Re:PHP 8 by tyingq on Thursday November 26, 2020 @05:18PM (#25223925)
Is there a reason returning undefined instead of true in those cases (string doesn't look like a number) would be worse?
Re:PHP 8 by xorcist on Saturday November 28, 2020 @06:22AM (#25236956)
Very few functions in Perl does that. It will emit a warning instead.

As to why that is, perhaps someone with more Perl knowledge can chime in. I suspect it has to do with undef being inconvenient for signalling failure, since its evaluation will be context dependent (an array of undef is true but a numeric undef is false).

Type conversion is built into the language at a fundamental level. Languages that borrows the syntax but not the type model can be confusing in cases, but Perl is pretty consistent once you get the basics.