for(my $count = 0; $count < @myarray; ) { unless(defined $myarray[$count]) { splice @myarray, $count, 1; } else{ $count++ } }