Public bug reported:

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';
    $

** Affects: perl (Ubuntu)
     Importance: Undecided
         Status: New

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

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

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

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to