You will get a different value for $cnt because you are actually extending the array each time.
From Perl 5.6.0,
delete may be used on an array element. It sets the element to its undefined state, but does not shift the index of the ones after them - use
splice for that. As with a hash,
delete returns the deleted value.
This does not buy you much over using undef, in fact undef can be more efficient, but
delete can be used on an array slice, which undef cannot.
The function
exists can also be used on an array element, but not on a slice. The result given by
exists is subtle. If the element was
delete'd then both
defined and
exists will return FALSE. If the element was set to undef, then
defined returns FALSE but
exists returns TRUE!