my $i = $#arry; while ( $i >= 0 ) { if ($arry[$i] == 0) {splice @arry, $i,1;} $i-- ; }