in reply to leaking into sort when sorting an empty set

Try this:
use Data::Dumper; sub foo { return (); } warn Dumper(sort {$a <=> $b} foo('1000'));
and you get what you expect.

Or try:

use Data::Dumper; sub foo { return (); } warn Dumper(sort(foo('1000')));
It looks like Perl thinks that foo is the sort function, and 1000 is what is being passed into the sort. Both those solutions disambiguate the situation.