Env.pm: Fix splice in list context
authorFather Chrysostomos <sprout@cpan.org>
Fri, 9 Nov 2012 20:50:59 +0000 (12:50 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 12 Nov 2012 06:17:30 +0000 (22:17 -0800)
It was passing an extra argument to splice, causing splice @PATH, 0, 0
to append ":0" to the environment variable.

dist/Env/lib/Env.pm
dist/Env/t/array.t

index 1f3713a..6e6cd8b 100644 (file)
@@ -211,7 +211,7 @@ sub SPLICE {
     my $length = shift;
     my @temp = split($sep, $ENV{$$self});
     if (wantarray) {
-       my @result = splice @temp, $self, $offset, $length, @_;
+       my @result = splice @temp, $offset, $length, @_;
        $ENV{$$self} = join($sep, @temp);
        return @result;
     } else {
index 9e87f4a..d029174 100644 (file)
@@ -6,7 +6,7 @@ use strict;
 use Test::More;
 
 plan(skip_all => "skipped for VMS") if $^O eq 'VMS';
-plan(tests => 11);
+plan(tests => 12);
 
 use Env  qw(@FOO);
 use vars qw(@BAR);
@@ -64,3 +64,7 @@ is_deeply(\@FOO, \@BAR, "Sort");
 splice @FOO, 1, 1, 'B';
 splice @BAR, 1, 1, 'B';
 is_deeply(\@FOO, \@BAR, "Splice");
+
+my $foo = $ENV{FOO};
+() = splice @FOO, 0, 0;
+is $ENV{FOO}, $foo, 'Splice in list context';