in reply to Array question

I won't repeat "use splice", :-), but I just would like to show you some spots of perldoc where that behaviour is described explicitly:

delete EXPR
Given an expression that specifies a hash element, array element, hash slice, or array slice, deletes the specified element(s) from the hash or array. In the case of an array, if the array elements happen to be at the end, the size of the array will shrink to the highest element that tests true for exists() (or 0 if no such element exists).
...
Deleting an array element effectively returns that position of the array to its initial, uninitialized state. Subsequently testing for the same element with exists() will return false. Note that deleting array elements in the middle of an array will not shift the index of the ones after them down--use splice() for that. See "exists".

Is the above a subtle RTFM? No, it's not, don't worry. It's just a I lost one hour on my code while I could lose just 5 minutes on the docs ;-)

Ciao!
--bronto

# Another Perl edition of a song:
# The End, by The Beatles
END {
  $you->take($love) eq $you->made($love) ;
}

Replies are listed 'Best First'.
Re: Re: Array question
by Theseus (Pilgrim) on Jul 10, 2002 at 20:44 UTC
    Believe it or not, I did view that very same manpage, and the splice() comment just completely got past me somehow. That's what happens when I stay at work late trying to find the solution to something that's been bugging me... *sigh*

      Ahah! :-) No problem brother, I know what you mean!

      Ciao!
      --bronto

      # Another Perl edition of a song:
      # The End, by The Beatles
      END {
        $you->take($love) eq $you->made($love) ;
      }