[Bug 1062836] Re: a2p wrongly considers string literal "0" is always false

Ralph Corderoy ralph at inputplus.co.uk
Sat Oct 6 13:25:43 UTC 2012


** Bug watch added: rt.perl.org/rt3/Public/ #115158
   http://rt.perl.org/rt3/Public/Ticket/Display.html?id=115158

** Also affects: perl5 via
   http://rt.perl.org/rt3/Public/Ticket/Display.html?id=115158
   Importance: Unknown
       Status: Unknown

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to perl in Ubuntu.
https://bugs.launchpad.net/bugs/1062836

Title:
  a2p wrongly considers string literal "0" is always false

Status in The Perl Programming Language:
  Unknown
Status in “perl” package in Ubuntu:
  New

Bug description:
  Perl always considers a scalar with the string value "0" as false due
  to a scalar's polymorphism.  awk does something similar, which is
  where Perl picked up the idea, but only if the string came from the
  user, e.g. an environment variable or read from a file.  If the string
  is a constant in the source then it's true, not false.  Perl's a2p(1)
  doesn't handle this subtlety.

      $ printf '%s\n' '0 f' '1 t' | awk '$1 && "0"'
      1 t
      $ printf '%s\n' '0 f' '1 t' | perl -e "$(a2p <<<'$1 && "0"')"
      $
      $ a2p <<<'$1 && "0"' | grep print
          print $_ if $Fld[1] && '0';
      $

To manage notifications about this bug go to:
https://bugs.launchpad.net/perl5/+bug/1062836/+subscriptions




More information about the foundations-bugs mailing list