use strict; use warnings; my @arry = (9,0,0,5,3,0,0,0,2,0,1,0); print "@arry \n"; my $i = 0; while ( $i <= $#arry) { if ($arry[$i] == 0) {splice @arry, $i,1;} $i++ ; } print "@arry \n";