sub Fun { $a = shift; return $a > 0 ? 1 : 0 } @a = (1,2,-3,4,-5,99); printf "%d, ",$_ for grep {Fun($_)} @a; #### 1, 2, 4, 99