note
betterworld
<blockquote><i>The delete operator doesn't really belong in the list. It removes pairs from a hash, but on an array it only undefines the value of an element.</i></blockquote>
This is not quite true. If you <tt>delete</tt> the last element of an array, the array will actually shrink:
<code>
my @array = qw/tiger dog cat/;
delete $array[2];
print scalar @array; # Output is 2
</code>
You can even have it funnier:
<code>
my @array = qw/tiger dog cat/;
delete $array[1];
print scalar @array; # Output is 3
delete $array[2];
print scalar @array; # Output is 1
</code>
However, this seemingly equivalent code does behave weird:
<code>
my @array = qw/tiger dog cat/;
delete $array[1];
print scalar @array; # Output is 3
splice @array, 2;
print scalar @array; # Output is 2
</code>
474794
474796