> -----Original Message----- > From: Michael Fowler [mailto:[EMAIL PROTECTED]] > Sent: Friday, December 21, 2001 2:20 PM > To: Bob Showalter > Cc: [EMAIL PROTECTED] > Subject: Re: Deleting from a list > > > On Fri, Dec 21, 2001 at 11:36:58AM -0500, Bob Showalter wrote: > > What version of Perl are you using? delete() for array elements > > seems to be a 5.6 feature. > > > > If you are using an earlier version, use splice(). > > delete and splice behave differently in certain cases; the > preferred methods > are to use splice, shift, and pop. > > Using delete on an any element, other than the end, returns > that element to > an uninitialized state; it's undef if you examine it, and > exists returns > false for that element. On the other hand, using splice on that same > element will remove it entirely from the array, thus > shrinking the array's > size. See perldoc -f delete.
Yes, you're right. delete $foo[3] leaves an undef in that position, while splice can shift the other elements down to close up the hole. Thanks. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]