in reply to any built in function to take out null arrays elements?

Since @userArray2 is empty, it doesn't add anything to @mainArray

my @userArray = qw(batman robin joker); my @userArray2; #this is a null array my @mainArray = (@userArray, @userArray2); print("Number of elements: ", scalar(@mainArray), "\n"); # 3

If you want to filter out elements of an array, grep is usually the way to go.

my @mainArray = ('batman', 'robin', undef, 'joker'); print("Number of elements: ", scalar(@mainArray), "\n"); # 4 @mainArray = grep { defined } @mainArray; print("Number of elements: ", scalar(@mainArray), "\n"); # 3

By the way, adding Array to your variable names is redundant. That's what @ means.