in reply to Newbie flabbergasted by string compare results
You’re just having precedence problems with the various operators. Change the second print statement to:
print 'a' cmp 'b', "\n"; # -1
i.e., use the comma operator instead of the concatenation operator. And repeat for the other print statements. You should then get the results you’re expecting.
Update: To clarify: the concatenation operator . has a higher precedence than the stringwise comparison operator cmp, so your second print statement is parsed as print 'a' cmp ( 'b' . "\n" ); But the comma operator , has lower precedence, so it parses as you expect. See Operator Precedence and Associativity.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|