Deborah wrote:
> 
> How does Perl interpret a string when used in a numeric comparison
> equation?
>   I accidently used a numeric comparison operator when I was comparing
> strings and I found that no matter what strings I compared, Perl always
> said they were equal.
> 
> Any other operation (such as <, >, != ) always proved false, but it was
> always true that 'stringA'=='Bstrg'.  Is it just saying that "it is
> true" that stringA and Bstrg are both strings? I thought it would count
> spaces or convert to numbers or something like that.  Well, actually, I
> first was surprised that it didn't give me an error since I used the
> wrong type of operator. What is it doing in this case?

It depends on what is in the string:

$ perl -le'
print "string" + 0;
print "   8 is a number" + 0;
print "   1e1  " + 0;
print "oops 8" + 0;
'
0
8
10
0

If perl can convert the leading characters to a number then it will,
otherwise the string has the numeric value of zero.


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to