Skip Menu |

This queue is for tickets about the Scalar-List-Utils CPAN distribution.

Report information
The Basics
Id: 128423
Status: new
Priority: 0/
Queue: Scalar-List-Utils

People
Owner: Nobody in particular
Requestors: rvtol [...] isolution.nl
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: uniq unexpectedly returns its scalar
Date: Tue, 5 Feb 2019 11:07:00 +0100
To: bug-Scalar-List-Utils [...] rt.cpan.org
From: "Ruud H.G. van Tol" <rvtol [...] isolution.nl>
When uniq() is entered via goto, it does something undesired: perl -Mstrict -wE' use List::Util (); sub AUTOLOAD { our $AUTOLOAD; my $caller_pkg= caller; my ($sub_pkg, $sub)= ($AUTOLOAD =~ /^(.*)::(.*)/x); if ( List::Util->can($sub) ) { my $cref; { no strict "refs"; $cref= \&{"List\::Util\::$sub"}; say "\ninjecting $AUTOLOAD"; *$AUTOLOAD= $cref; } $ARGV[0] ? goto $cref : return $cref->(@_); } die "unknown: $AUTOLOAD"; } my @data= (-1, 42, 5, 7, 5 ); say "data: @data"; for (1..2) { say "shuf: @{[ shuffle(@data) ]}"; say "uniq: @{[ uniq(@data) ]}"; } ' 1 data: -1 42 5 7 5 injecting main::shuffle shuf: 42 7 5 -1 5 injecting main::uniq uniq: 4 shuf: 7 5 42 -1 5 uniq: -1 42 5 7 -- Greetings, Ruud
Subject: Re: [rt.cpan.org #128423] AutoReply: uniq unexpectedly returns its scalar
Date: Tue, 5 Feb 2019 13:47:41 +0100
To: bug-Scalar-List-Utils [...] rt.cpan.org
From: "Ruud H.G. van Tol" <rvtol [...] isolution.nl>
Comparing List::MoreUtils::distinct() perl -Mstrict -wE' my @PACKAGES= qw( List::Util List::MoreUtils Scalar::Util ); sub AUTOLOAD { our $AUTOLOAD; my ($pkg, $sub)= ($AUTOLOAD =~ /^(.*)::(.*)/); for my $sub_pkg ( @PACKAGES ) { $sub_pkg eq "main" or $INC{$sub_pkg =~ s~::~/~gr .".pm"} or say "Loading $sub_pkg" and eval "require $sub_pkg" or die $@; if ( my $sub_ref= $sub_pkg->can($sub) ) { say sprintf "\ninjecting $AUTOLOAD\t-> %s::%s", $sub_pkg, $sub; { no strict "refs"; *$AUTOLOAD= $sub_ref } $ARGV[0] ? goto $sub_ref : return $sub_ref->(@_); } } die "unknown $AUTOLOAD"; } my @data= (-1, 42, 5, 7, 5 ); say "data: @data"; for (1..2) { say "dist: ".join " ", distinct(@data); say "shuf: ".join " ", shuffle(@data); say "uniq: ".join " ", uniq(@data); } ' 1 data: -1 42 5 7 5 Loading List::Util Loading List::MoreUtils injecting main::distinct -> List::MoreUtils::distinct dist: -1 42 5 7 injecting main::shuffle -> List::Util::shuffle shuf: -1 7 5 42 5 injecting main::uniq -> List::Util::uniq uniq: 4 dist: -1 42 5 7 shuf: 7 -1 42 5 5 uniq: -1 42 5 7 -- Greetings, Ruud