@output = @input[ grep $_ & 1, 0 .. $#input]; #### ($mod, $val) = (2, 1); @output = @input[ grep $_ % $mod == $val, 0 .. $#input];