in reply to Re: D'Orcish Maneuver
in thread D'Orcish Maneuver

Well, duh. Of course it gives a ton of warnings. But that's not the fault of the orkish maneuver - it's the fault of the set of elements you want to sort. You'd get the same warnings if you'd used a plain sort, or an ST - the warnings come from returning undefined values in the function that maps elements to sort to <=> operands.
#!/usr/bin/perl use 5.010; use strict; use warnings; sub expensive_call { $_[0] == -1 ? undef : $_[0] } say $_ // "[undef]" for sort {expensive_call($a) <=> expensive_call($b +)} 0,1,-1,-1,0,2; __END__ Use of uninitialized value in numeric comparison (<=>) at /tmp/s line +9. Use of uninitialized value in numeric comparison (<=>) at /tmp/s line +9. Use of uninitialized value in numeric comparison (<=>) at /tmp/s line +9. Use of uninitialized value in numeric comparison (<=>) at /tmp/s line +9. Use of uninitialized value in numeric comparison (<=>) at /tmp/s line +9. Use of uninitialized value in numeric comparison (<=>) at /tmp/s line +9. Use of uninitialized value in numeric comparison (<=>) at /tmp/s line +9. 0 -1 -1 0 1 2
I complete fail to get the point you're trying to make.

Replies are listed 'Best First'.
Re^3: D'Orcish Maneuver
by ikegami (Patriarch) on May 04, 2011 at 19:10 UTC

    You'd get the same warnings if you'd used a plain sort, or an ST

    So just use those, then. The whole point of the OP's code is that it's suppose to be able to handle undef. Since it doesn't, it's a bug.