I definitely agree that a subroutine reference is a very good solution, perhaps the best.
In reply to Re^2: grep { $var } @arr by Laurent_R in thread grep { $var } @arr by igelkott