in reply to Is it possible to sort using a coderef, without first storing the coderef in a scalar

tye provided the answer in CB
<tye> as to /why/ that distinction matters: it is a parser restriction (and parsing sort arguments is rather buggy anyway)
<tye> perl -MO=Deparse -e "sort foo(), <>" says "sort foo (), <ARGV>;", which leads me to think that the space is important there
Investigated further and this is what I found:
perl -MO=Deparse -e 'sub a {}; my $r = \&a; sort $r (1,2)' + sub a { } my $r = \&a; sort $r 1, 2;
perl -MO=Deparse -e 'sub a {}; sort \&a (1,2)' sub a { } sort \(&a(1, 2));
  • Comment on Re: Is it possible to sort using a coderef, without first storing the coderef in a scalar
  • Select or Download Code