in reply to Sorting result of function call
I don't know the details of what is going wrong, but I suspect that it is due to the attempts of sort to interpret it's first argument as a comparison sub or block.
If you put in an explicit { $a cmp $b } in as the first parameter, all of your tests do the same thing - print "called:array:13".
It's a bit ambiguous actually - should "sort subname" be interpreted as "using this sub as the sort comparison routine, sort the empty list" or "call this sub in list context and sort the results with the default sort comparator".
The behaviour is surprising on the face of it, but I'm not (yet) sure it's wrong. Yet another reason to eschew prototypes (in this case, that of sort) I suppose.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Sorting result of function call
by Hofmator (Curate) on Dec 20, 2006 at 09:58 UTC | |
by jbert (Priest) on Dec 20, 2006 at 10:18 UTC | |
by ysth (Canon) on Dec 20, 2006 at 10:52 UTC |
In Section
Seekers of Perl Wisdom