in reply to shifting arguments

Stirctly speaking, shift() can be used on any array to remove the top (0th) element and return it. But, shift() defaults to @_ if no array is supplied. Since shift is removeing and returning only the first (0th) element, assigning it's return to and array does not work. But, since Perl always tries it's hardest, it take the one value from the right (the return from shift) and assigns it to the first element on the left. Then, when there is no second value, it simply assigns undef to the folloing vars. Thats the simple version, without getting into stacks and such
can't sleep clowns will eat me
-- MZSanford

Replies are listed 'Best First'.
Re: Re: shifting arguments
by Ea (Chaplain) on Aug 23, 2001 at 13:15 UTC
    Well and good, but I swear blind (maybe just myopic) that, when called in a list context, shift would depopulate @_ faster than Jimmy-Crack-Corn. Perhaps it only populates @list that way and not ($a, $b, $c).

    I'm off to do some experiments
    <sound of rustling pages and rummaging through dusty tomes>