in reply to Re: Slicing an array variable with a -1 or any negative number doesn't work
in thread Slicing an array variable with a -1 or any negative number doesn't work

Ok, I got it.
-1 or other -x (negative numbers) in slices, can only work with commas, but not with ..
I see.

Thank You.

  • Comment on Re^2: Slicing an array variable with a -1 or any negative number doesn't work

Replies are listed 'Best First'.
Re^3: Slicing an array variable with a -1 or any negative number doesn't work
by shmem (Chancellor) on Nov 29, 2017 at 12:47 UTC
    -1 or other -x (negative numbers) in slices, can only work with commas, but not with ..

    Nope. The point is that ".." counts up. These work:

    @letters = ('a'..'z'); say for @letters[-5..-1]; say for @letters[reverse(-1..0)];
    perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'