in reply to Trying to slice off all array elements but the last one

Negative ranges don't work. Try instead:

reverse( @{ $arrayref }[ -2 .. 0 ])

Update: I misread the question, but that doesn't mean that negative ranges don't work. :)

Replies are listed 'Best First'.
Re: Re: Trying to slice off all array elements but the last one
by Paladin (Vicar) on Feb 16, 2004 at 20:56 UTC
    That gets elements -2, -1, and 0. i.e. the second to last, last, and first elements, then reverses them, giving you the first, last, then second to last elements
Re: Re: Trying to slice off all array elements but the last one
by talexb (Chancellor) on Feb 16, 2004 at 20:58 UTC

    Interesting, but it fails .. I get indices -2, -1 and 0.

    Alex / talexb / Toronto

    Life is short: get busy!