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

Consider what happens before the splice, when $i is 1:

You need to keep spliceing while it remains zero, change your if to a while.

Now think about what happens when you've just spliced that last 0. $i points past the end of the array, so you need to add a check for that into the while condition:

while ( $i <= $#arry && $arry[$i] == 0 )

Having said all of that, GrandFather is right. Just use grep.