in reply to confused: string and number comparison

I think that Perl is taking the string "abcd" and attempting to convert it to a number as you are doing a numerical comparison. Strings that do not start with a digit are numified to 0 (zero) as far as I am aware. Therefore 0 == 0 is true.

Cheers,

JohnGG

Replies are listed 'Best First'.
Re^2: confused: string and number comparison
by ikegami (Patriarch) on Mar 23, 2011 at 15:51 UTC

    Numbers can start with "." and "-" too.

    >perl -wE"say 0+'.4'" 0.4 >perl -wE"say 0+'-6'" -6