in reply to Sorting result of function call
That second one is a bit surprising, but when you look at perldoc -f sort:
It's not exactly DWIM. But we humans get a lot of advantage from understanding that subroutine name. It's moderately likely that you'll pass an empty list into a sort in code, and it would be highly annoying if your sort routine was sometimes interpreted as a source of values depending on if your list was populated. So, I think this is good behavior - you have to be very explicit for it not to be considered the sort rules function.
sort SUBNAME LIST sort BLOCK LIST sort LISTIt sort of makes sense that 'sort get_stuff()' hits the first signature - it's sort, using the sorting rules in subname get_stuff, of an empty list.
It's not exactly DWIM. But we humans get a lot of advantage from understanding that subroutine name. It's moderately likely that you'll pass an empty list into a sort in code, and it would be highly annoying if your sort routine was sometimes interpreted as a source of values depending on if your list was populated. So, I think this is good behavior - you have to be very explicit for it not to be considered the sort rules function.
-- Kirby, IMDb.com
|
---|
In Section
Seekers of Perl Wisdom