Skip Menu |
 

This queue is for tickets about the CPAN CPAN distribution.

Report information
The Basics
Id: 80118
Status: new
Priority: 0/
Queue: CPAN

People
Owner: Nobody in particular
Requestors: dschrag [...] oneupweb.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in:
  • 1.9202
  • 1.9600
Fixed in: (no value)



Subject: Using 'splice' on configuration lists [PATCH]
Download (untitled) / with headers
text/plain 857b
I'm migrating from Perl 5.8 to 5.10 and beyond (finally!) and noticed that a script I used within cpan doesn't do the same thing as it used to. Back before CPAN::HandleConfig.pm, the arguments to the "o conf urllist splice ..." were passed directly to the perl 'splice' function. I was using this: Show quoted text
cpan> o conf urllist splice 1
to remove all but the primary (first) url in the list. Imagine my surprise when this no longer worked with modern perls! Since it is not documented otherwise, I consider this a bug for it not to behave just like perl's splice. However, for safety and backward compatibility, my patch still does not allow "o conf urllist splice" (no arguments) to clear the entire url list, the same as recent CPAN versions do not. It only permits clearing the "tail" of the list, as in the example above, when the "offset" is non-zero. DLS
Subject: CPAN_config_splice.patch
--- perlbrew/perls/perl-5.14.2/lib/5.14.2/CPAN.pm.org 2012-10-05 13:26:27.000000000 -0400 +++ perlbrew/perls/perl-5.14.2/lib/5.14.2/CPAN.pm 2012-10-10 16:06:31.000000000 -0400 @@ -1920,7 +1920,12 @@ appends a list of valued to the list. Likewise, C<o conf KEY splice LIST> passes the LIST to the corresponding -splice command. +splice command. It departs from the perl function only in that an +C<offset> of zero without an explicit C<length> will set a length of +zero (i.e., a no-op). Therefore, C<o conf KEY splice 0> will I<not> +clear the entire list. [Note: Many recent versions of CPAN did not allow +saying C<o conf KEY splice 1> to remove all but the first item of a list. +This is now permitted.] Finally, any other list of arguments is taken as a new list value for the KEY variable discarding the previous value. --- perlbrew/perls/perl-5.14.2/lib/5.14.2/CPAN/HandleConfig.pm.org 2012-10-05 13:26:27.000000000 -0400 +++ perlbrew/perls/perl-5.14.2/lib/5.14.2/CPAN/HandleConfig.pm 2012-10-10 15:14:49.000000000 -0400 @@ -168,8 +168,14 @@ $changed = 1; } elsif ($func eq "splice") { my $offset = shift @args || 0; - my $length = shift @args || 0; - splice @{$CPAN::Config->{$o}}, $offset, $length, @args; # may warn + if (@args || $offset == 0) { + # if $offset is zero, we force an omitted length to zero + # prevents clearing the whole list with no length given (converts to noop) + my $length = shift @args || 0; + splice @{$CPAN::Config->{$o}}, $offset, $length, @args; # may warn + } else { + splice @{$CPAN::Config->{$o}}, $offset; # allow clearing all but the first + } $changed = 1; } elsif ($func) { $CPAN::Config->{$o} = [$func, @args];


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.