for $i(0..$#array) { splice @array, $i, 1 if $array[$i] == 5; } #### for (@array) { ... if $_ == 5. }