Jay Savage wrote: > On Wed, Oct 8, 2008 at 11:24 AM, Rob Dixon <[EMAIL PROTECTED]> wrote: >> >> The return value of exists() is the definition of whether an array or hash >> elements exists. It does exactly what it is documented to do and does not >> lie. >> >> The idea of non-existent mid-range array elements is unusual, although there >> is >> at least Lua that does a similar thing. >> >> splice() cannot make array elements non-existent except when the length of >> the >> array is changed and tail elements vanish. To expect delete() to behave the >> same >> way as splice() is to be dissatisfied with the Perl language definition: they >> are different operations. > > No argument. The definitions of exists is "tests positive for > exists()," and a tautology is a thing which is tautological. In any > case, I'm not dissatisfied with the behavior. As I said, this is why > we have both delete and splice, which both have uses. > > But the issue I was responding to isn't whether the element exists, it > was your rebuff of John's assertion that delete does not always remove > the item, which is correct. > > The element may no longer *exist*, but it is not *removed* (that is, > the *structure* of the array is not modified) unless there are no > remaining elements that exist between the element being deleted and > the final element of the array. In other cases "deleting an array > element effectively returns that position of the array to its initial, > uninitialized state." That is, the element continues float out there > in the same existential limbo as the elements of pre-sized arrays. > > This distinction between canonical existence and logical existence--or > perhaps more properly the distinction between the existence of an > element and of a position--is important because, while useful, the > distinction does have implications for the value of $#array, the > return value of scalar(), and the behavior of while and foreach > blocks, among others, not just the output of Data::Dumper.
I don't think so. $#array returns the index of the last existent element of the array. The one which pop() will delete and return, and the one after which push() will add an element. I'm not sure what you mean about 'while', but an array evaluates as true if it has any existent elements. 'for' iterates over a list, and Perl derives a list from an array by inserting undefined values where there are non-existent elements before the end of the array. It may not be fully documented but it is all self-consistent and works well. Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/