for my $i ( 0 .. $#to_clean ) { next if defined $to_clean[ $i ] and $to_clean[ $i ]; next unless $to_clean[ $i ] eq ''; }