On Feb 7, Leon said:
>Apart from the fact that == is used for numeric comparison whilst eq is used
>for string comparison, it would be of interest to note that == when used
>with strings forces the strings to be read in numeric context which is zero.
Not all strings have a numeric value of zero.
for ("foo", "123", "foo123", "123foo") {
print "$_ + 0 = ", $_ + 0, "\n";
}
__END__
foo + 0 = 0
123 + 0 = 123
foo123 + 0 = 0
123foo + 0 = 123
Perl attempts to pull a valid numerical value from the front of the
string, and uses zero if no value is found.
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]