rlm@0: sub filter rlm@0: { rlm@0: rlm@0: $ref = shift; rlm@0: @list = @_; rlm@0: my @ret = (); rlm@0: rlm@0: for $element(@list) rlm@0: { rlm@0: if ($ref->($element)) rlm@0: { rlm@0: push @ret, $element; rlm@0: } rlm@0: } rlm@0: rlm@0: return @ret rlm@0: rlm@0: } rlm@0: rlm@0: rlm@0: rlm@0: rlm@0: @test = (1,2,3,4,5,6); rlm@0: rlm@0: sub even rlm@0: { rlm@0: return ($_[0]%2 == 0); rlm@0: } rlm@0: rlm@0: @rr = &filter(\&even, @test); rlm@0: rlm@0: print "@rr";