On Wed, 18 Oct 2000 08:38:15 -0700, John W Baxter wrote: >>> Cool. The expression $list['0 but true'] works like $list[0] !! >> >>Perl even goes so far as to special case the string '0 but true'; when it >>is converted to a number, Perl does not produce an "argument is not >>numeric" warning. > >That's not a special case...try > >print 0 + "77 seventy-seven" + "\n"; > >When a number is needed and Perl has a string, it converts as much of the >string as possible to a number and uses that. Oh, blimey: far too many people seem to be running Perl code without warnings enabled. It does catch a lot of bugs, you know! $^W = 1; print 0 + "77 and the rest"; --> Argument "77 and the rest" isn't numeric in addition (+) at test.pl line 3. 77 >Hence, "twenty" == "thirty" is true, since both are 0. That's true. That's one of the typical bugs that -w will catch. The special thing is that there is NO warning for the conversion of the string "0 but true" to a number. The value will be zero, obviously. OTOH, it's not the only string for which this is the case: other zero valued strings are True as well: "0E0", "0.000", ".0", "0.", "-0". All zero, all true. So this exception was actualy unnecessary. -- Bart. # ===== Want to unsubscribe from this list? # ===== Send mail with body "unsubscribe" to macperl-request@macperl.org