Closed FGasper closed 4 years ago
we have ||=
, //=
, what about \\=
:-)
In a sense this points out the duality of the string-or-number model of Perl's type system in that is demonstrates the question of how you ask the "truth" of a value really depends on whether you wanted the stringy truth or the numerical truth.
# stringily false
undef, ""
# numerically false
undef, 0, # plus "" which is exempt from number->string conversion warnings
Precisely. Perl’s standard “or” makes sense when our scalars are numbers, but not when they’re strings.
discussion moved to https://github.com/Perl/perl5/issues/17191
Over the years I’ve not infrequently encountered this:
.. which undesirably rejects
0
as input.Defined-or doesn’t help here because the form submits regardless.
It would be very helpful if Perl (7?) added a “length-or”: undef and q// are falsy, but everything else is truthy.
Thank you!