sub remove5s { my($aref)=@_; for(my $i=0; $i<@$aref; $i++) { $_=$$aref[$i]; unless ($_ % 5) { splice(@$aref, $i, 1); $i--; } } }