in reply to can't remove all zeroes from an array
use strict; use warnings; my @arr = (9, 0, 0, 5, 3, 0, 0, 0, 2, 0, 1, 0); print qq{@arr\n}; for my $idx ( reverse 0 .. $#arr ) { splice @arr, $idx, 1 unless $arr[$idx]; } print qq{@arr\n};
This produces
9 0 0 5 3 0 0 0 2 0 1 0 9 5 3 2 1
I hope this is useful.
Cheers,
JohnGG
|
|---|