in reply to coderef assignment with and without eval

Try this with both versions of make_grep:
$a = make_grep("a"); $b = make_grep("b"); print &$a(qw(ack thpt barf)), "\n"; print &$b(qw(ack thpt barf)), "\n";
With the eval, you get "ackbarf" and "barf", which is correct. Without it, you get "ackbarf" twice. String eval compiles a new sub. Without the eval, the two subs share the same compiled regex. Once the /o causes it to lock down, it is locked for both subs -- even though they see different values of $pat.

This technique is kind of nasty. Use qr//, like suaveant says. Be sure to compile the regex in the right place.

sub make_grep { my $pat = shift; my $re = qr/$pat/; return sub { grep /$re/, @_ } }