To initialize an @array
to nothing, just do:
my @test = ();
Currently you're doing:
my @test = (undef);
Which, as you are observing, is assigning the array a single value.
To clear an already declared array, you can use undef
like so:
undef @test;