in reply to Check if array is null

Is there any way to check if an array has been initialized? I am executing a command and that output is going into an array. If the command has no output then the array does not get initialized. Is there a way to check that?
Your assumptions are wrong:

after

my @array1; my @array2 = some_code();
is run, @array1 and @array2 will both be initialized. @array1 will be empty: you can check for that using:
if (@array1) { print "not empty\n"; }

@array2 will contain whatever some_code() returns. some_code() will allways return a list, because it's called in list context (caused by the assignment to @array2).

If some_code returns like this:

return (); # an empty list
@array2 will be empty, like @array1 above.

If some_code returns like this:

return undef; # undefined scalar
@array2 will contain 1 element which will be undefined.

If some_code returns like this:

return; # "return false"

@array2 will be empty (return; without arguments returns an empty list in list context, and undef in scalar context)

If some_code does not use a return statement, the last statement in some_code will be executed in list context and its value will be returned.