in reply to grep { $var } @arr

You are not using a pattern which, to me, implies m// or index() use; you are actually using a code block.

Use a list of sub references to iterate over instead ...

@test = ( sub { $_[0] < 3 } ); for my $t ( @test ) { print join q[ ] , grep $t->( $_ ), 1 .. 5; }