in reply to Re: How to cut strings from the end
in thread How to cut strings from the end

Could you explain how this works? I was trying these days to dismiss the first element of an anonymous list, then I got this code:

(undef, @list) = split /\s+/, $str;
I was wondering if something like that could work, but it doesn't:
@list = (split /\s+/, $str)[1..$#a];
Thanks in advance.

Igor 'izut' Sutton
your code, your rules.

Replies are listed 'Best First'.
Re^3: How to cut strings from the end
by japhy (Canon) on May 30, 2006 at 14:05 UTC
    His code assumes @a is empty, which means $#a returns -1, so he's doing (...)[-1 - 2 .. -1] which is just (...)[-3 .. -1]. Your case cannot be handled in a similar manner -- you'd need to know the size of the list being returned by split(). Your first approach is fine.

    Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
    How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart