There is an element in the array because you assigned it. Consider the following:
@array = undef;
They look the same, but the first line is different from the other two (which are equivalent). The first line leads to an array with one element ( undef value). The other two spawn an empty array. In Perl, undef is both a value and an operator. The first line uses it as a value, the last line uses it as an operator.
Usually there is no need to clear the array. They are declared empty:
my @array;
source share