[EMAIL PROTECTED] (John W. Krahn) writes: > "Michael R. Wolf" wrote: > > > > [EMAIL PROTECTED] (John W. Krahn) writes: > > > > > > Are you sure there are only three? :-) > > > > > > $ perl -le' > > > print qq(undef is FALSE) unless undef; > > > print qq("" is FALSE) unless ""; > > > print qq("0" is FALSE) unless "0"; > > > print qq(0 is FALSE) unless 0; > > > print qq(0e0 is FALSE) unless 0e0; > > > ' > > > undef is FALSE > > > "" is FALSE > > > "0" is FALSE > > > 0 is FALSE > > > 0e0 is FALSE > > > > You caught me; very nice counterproof. You were obvoiusly > > right about the "0" (see "Camel citation below), but I'd > > suggest that 0 and 0e0 are the same - they're both scalar > > numeric zero. I could be convinced otherwise if there's a > > reason to make the distinction between these: > > > > scalar numeric float zero (0e0) > > scalar numeric int zero (0) > > > > I originally suggested 3 false values, you counterproposed > > 5, and now I'm counter-counterproposing 4. > > > > I've modified the test (with answers) as below. > > > > test> Any value that is not false is true. What values indicate false? > > test> > > test> string -- _""____ _"0"___ > > test> > > test> numeric -- _0_____ > > test> > > test> other -- _undef_ > > test> > > > > When scoring it, I'll accept 0e0 instead of or in addition > > to 0, but I'm not likely to get it since I won't mention the > > distinction in class. There isn't really an user-level > > distinction between int and float like there is a > > distinction between string/numeric and scalar/array. > > The reason I threw in the 0e0 is that although 0 stringified is also > false this is not true for "0e0" which is true. > > $ perl -le' > print q("0e0" is ), "0e0" ? "TRUE" : "FALSE"; > print q( 0e0 is ), 0e0 ? "TRUE" : "FALSE"; > ' > "0e0" is TRUE > 0e0 is FALSE
Camel> Truth in Perl is always evaluated in a scalar Camel> context. (Other than that, no type coercion is done.) So Camel> here are the rules for the various kinds of values that a Camel> scalar can hold: Camel> Camel> Any string is true except for "" and "0". Camel> Camel> Any number is true except for 0. Camel> Camel> Any reference is true. Camel> Camel> Any undefined value is false. Camel> Any string is true except for "" and "0". You have demonstrated string non-false with the specific string "0e0". Camel> Any number is true except for 0. But you have not shown that 0 and 0e0 different cases of numeric non-false. Can you show that stringify(0) and stringify(0e0) (or any other path that starts with different numeric literals) yield different results vis-a-vis the only false string values ("" and "0")? If not, I re-assert that there are 4 false values and that every thing else is true. "" "0" 0 undef -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]