[sf-perl] Sort subroutine didn't return single value at -e line 1.

Bill Moseley moseley at hank.org
Fri Apr 5 14:21:15 PDT 2013


Could someone explain what's happening here with sort?

5.14.2:

$ perl -wle 'use Data::Dumper; use List::MoreUtils "uniq";  print Dumper
[uniq 3,1,3,2]'
$VAR1 = [
          3,
          1,
          2
        ];

Might be nice to sort those -- like one would do in a shell:


$ perl -wle 'use Data::Dumper; use List::MoreUtils "uniq";  print Dumper
[sort uniq 3,1,3,2]'
$VAR1 = [
          1,
          2,
          3,
          3
        ];


Got an extra value there?


That code above was in one of our unit tests, and when I ran with 5.16.1 I
then get:


$ perl -wle 'use Data::Dumper; use List::MoreUtils "uniq";  print Dumper
[sort uniq 3,1,3,2]'
Sort subroutine didn't return single value at -e line 1.


This works, though:

$ perl -wle 'use Data::Dumper; use List::MoreUtils "uniq";  print Dumper
[uniq sort 3,1,3,2]'
$VAR1 = [
          1,
          2,
          3
        ];



-- 
Bill Moseley
moseley at hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/sanfrancisco-pm/attachments/20130405/9c4e18e0/attachment.html>


More information about the SanFrancisco-pm mailing list