in reply to Re^2: Parse data representing hash
in thread Parse data representing hash

Yes, splice is likely the best approach. From its documentation:

Removes the elements designated by OFFSET and LENGTH from an array [...] If LENGTH is omitted, removes everything from OFFSET onward.

So with zero-based arary indexing, it really is as simple as splice @keychain, $tabs_count;, yes.

You could also use an array slice, BTW, e.g. @keychain = @keychain[0 .. ($tabs_count - 1)];, but that's less elegant and idiomatic.

Replies are listed 'Best First'.
Re^4: Parse data representing hash
by peterp (Sexton) on Jun 29, 2014 at 18:51 UTC

    Thanks again

    Just to add to these approaches, another approach suggested below is to do $#keychain = $tabs_count

    Regards

      Oh, nice! I wasn't aware that you could assign to $#... to shorten (and grow?) an array. Thanks for sharing that tip, I doubt I'd have seen it below.