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

@{$arrayref}[0 .. ($#$arrayref - 1)];

The $#$arrayref gets the index of the last element, and you subtract 2 from that to get the index of the third to last element (the last one you want). Update: Mis-read the OP as all except last 2 elements. Fixed.

Replies are listed 'Best First'.
Re: Re: Trying to slice off all array elements but the last one
by talexb (Chancellor) on Feb 16, 2004 at 21:04 UTC

    Thanks .. you reply is almost correct. It's actually

    @{$arrayref}[0 .. ($#{$arrayref} - 1)];
    but thanks for replying, I appreciate it. The solution involving temporary arrays seemed so ugly. And I added extra braces to remind me (in a months time) that I'm dealing with an ARRAY referece.

    Alex / talexb / Toronto

    Life is short: get busy!