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

[perl #88740] RFE: allow length(undef)=>0 (w/no warnings)

Thread Previous
Jesse Luehrs via RT
July 3, 2012 18:10
[perl #88740] RFE: allow length(undef)=>0 (w/no warnings)
Message ID:
undef in numeric context evaluates to 0, so your example of summing up a
bunch of lengths will still work identically (although the warning that
is generated is now "Use of uninitialized value in addition (+)" instead
of "Use of uninitialized value in length". Also, if you want to suppress
the warning, previously you had to do "(defined($str) && length($str))
|| 0", where now you can do just "length($str) || 0", since passing
undef to length no longer warns. I'm inclined to close this ticket,
unless anyone can see anything here that should be done.


via perlbug:  queue: perl5 status: open

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