@array has a defined value, period. ... therefore @array is not undefined. ... Even split ",", undef; returns an empty list, which is a defined value.
Sorry, this is incorrect, arrays don't have a concept of "(un)defined", only the elements of an array do - an array is either empty, or not empty. Whether or not the elements of an array are undef or not is a different question - even an array of one undef element is considered "true" by Perl because the array is non-empty.
$ perl -wMstrict -Mdiagnostics -le 'my @array; print defined(@array)'
Can't use 'defined(@array)' (Maybe you should just omit the defined()?
+) at -e
line 1 (#1)
(F) defined() is not useful on arrays because it
checks for an undefined scalar value. If you want to see if the
array is empty, just use if (@array) { # not empty } for example.
Uncaught exception from user code:
Can't use 'defined(@array)' (Maybe you should just omit the define
+d()?) at -e line 1.
$ perl -wMstrict -le 'my @array=(undef); print @array?"true":"false"'
true
Once you execute my @array = split ( "," , $_ );, @array has a defined value, period.
$ perl -wMstrict -MData::Dump -e 'my @array; dd @array; $_="";
@array = split(",",$_ ); dd @array'
()
()
If split could return undef ... but split doesn't do that.
$ perl -wMstrict -MData::Dump -e 'dd split /-|(x)/, "-", -1'
("", undef, "")