The right way to do it here is from @ dave-cross
Fast and dirty if you are not ready to fix your split:
foreach(@plain){ if( ( defined $_) and !($_ =~ /^$/ )){ push(@new, $_); } }
edit: how does it work
There will be more elegant and effective ways to do this than the above, but, like anything else, perl-y tmtowtdi! How it works:
Loop through the @plain array, making $_ set to the current array element
foreach(@plain){
Check the current item to see if we are interested in it:
( defined $_) # has it had any value assigned to it !($_ =~ /^$/ ) # ignore those which have been assigned a blank value eg. ''
If the current item passes these checks, click it on @new
push(@new, $_);
beresfordt
source share