The delete() function has a companion exists() function (also formerly only used with hashes) that detects the difference between an array element that has been deleted and onethat has been undefined: We'd expect this if we'd used delete() as well however, the methods are not entirely equivalent. This snippet prints (ignoring warnings)::::::5:6 One may think that the delete() function (formerly only allowed on hash elements) is nothing more than simply undef()'ing elements in an array, assigning either multiple undef values to multiple elements, or perhapsĪssigning an empty list to multiple values: That slice need not be a contiguous range of elements:ĭelete splice() function may also be used to remove a range of elements from an array, but not a discontiguous slice: # remove 3 elements starting at index 0.
You can see that the delete() function only deletes the value at index 3 in the array, while the splice() function removes the slot entirely and shifts the remainder of the array down to fill in the gap.The delete() function can also be used on an array slice as well as a single element.
Use of uninitialized value in join or string at - line 3. Print join(':', snippet produces the following output: