Amit Saxena wrote:
On Mon, Jul 21, 2008 at 2:11 AM, Rob Dixon <[EMAIL PROTECTED]> wrote:
If you were using the <=> operator to compare non-numeric strings you would get a warning, but any scalar value is a valid string so you will get no warnings if you compare numeric values with the cmp operator.

Sorting numbers as strings causes them to be sorted in dictionary order, which is different from numeric order if the numbers have the same number of digits. So 2 is greater than 11 in the same way that 'B'is greater than 'AA'.

That means you want to mention that always use "cmp" instead of "<=>" for any kind of data, numeric or non-numeric.

That's an odd conclusion, considering the second para above.

Preventing warnings is not all there is. Correct output is somewhat important as well...

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to