in reply to Re: Sorting Puzzle (just sort)
in thread Sorting Puzzle

$a <=> $b already forces $a and $b to be interpretted as numbers, always.
It doesn't appear to with perl 5.8.2:
use strict; use warnings; my $d1 = '2007030110300020070301133000'; my $d2 = '2007030110300020070301143000'; printf "plain = %d\n", ($d1 <=> $d2); { use bigint; printf "bigint = %d\n", ($d1 <=> $d2); } { use bigint; printf "bigint-0 = %d\n", (($d1 -0)<=> ($d2-0)); }
Output:
plain = 0 bigint = 0 bigint-0 = -1

Replies are listed 'Best First'.
Re^3: Sorting Puzzle (just sort)
by tye (Sage) on Feb 20, 2007 at 22:31 UTC

    That doesn't show $d1 and $d2 being compared as not numbers and so doesn't contradict my point. I guess the other points are about getting bigint to magically turn numeric expressions into objects. I'm not a fan of such subtle magic and so didn't recommend the use of bigint.pm and see no real value for it here anyway. But thanks for indirectly clarifying those points.

    - tye