in reply to can't remove all zeroes from an array

The smallest change needed to fix your code is to only increment $i when you don't remove an element.
while ( $i <= $#arry) { if ($arry[$i] == 0) {splice @arry, $i,1;} else {$i++;} }

Replies are listed 'Best First'.
Re^2: can't remove all zeroes from an array
by bart (Canon) on Aug 10, 2007 at 00:26 UTC
    Or, alternatively, move backwards.

    When you splice like this, items with a larger index shift forward, but those with a lower index remain in place — so the problem simply vanishes by looping back to front.

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