Subject: | Carp::croak must be predeclared; uniq stringifies while filtering |
The following code:
---
use List::MoreUtils qw/uniq/;
my $a = [];
print ( uniq $a, "$a" ), "\n"
---
prints out a 1-entry list, whereas it should produce a 2-entry list. This is because the uniq
filter stringifies. The attached diff fixes this in the pure-Perl version, as well as remedying an
error where 2 occurrences of Carp::croak threw an error (because they were compiled before the
corresponding require Carp was executed).
Subject: | no-stringify.patch |
--- MoreUtils.pm 2008-11-20 11:54:40.000000000 -0500
+++ /Volumes/LS1/lspice/.perl/lib/perl5/darwin-2level/List/MoreUtils.pm 2006-07-02 11:26:35.000000000 -0400
@@ -218,8 +218,6 @@
return each_arrayref(@_);
}
-sub Carp::croak;
-
sub each_arrayref
{
my @arr_list = @_; # The list of references to the arrays
@@ -282,7 +280,7 @@
sub uniq (@) {
my %h;
- map { $h{ ref $_ ? 'r' . $_ : 's' . $_ }++ == 0 ? $_ : () } @_;
+ map { $h{$_}++ == 0 ? $_ : () } @_;
}
sub minmax (@) {