in reply to sub returning undef
my @array = @_;
There's your array, even if $array[0] yields undef, @array still is a defined array with one single element.
Test for $_[0] being undef, before you create another array.