>>>>> "sw" == shawn wilson <ag4ve...@gmail.com> writes:

  RD> Perl has no proper boolean values. Instead, the boolean operators
  RD> treat zero, undef, and the null string '' all as false. Anything else
  RD> is true.

  sw> to be pedantic, '0' is also false. it isn't exactly the same as 0.


  sw> come again with that? how is:
  sw> $string = 0; #different from
  sw> $string = '0';

  sw> they both define $string as something, right?

but they are different actual values. sure perl will convert from one to
the other but i have run into issues with 0 vs '0'. i am comparing
values from input data and from a db using json which stringifys its
values. but it does it differently for 0 and '0' which made the
comparisons fail. the module is checking the internal flags to see if
something is a string or an integer and encoding the json accordingly. i
had to force my string numbers to integers (by adding 0) to make it work
correctly.

and we aren't testing defined, but boolean. defined only checks for
undef.

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to