http://qs1969.pair.com?node_id=854996


in reply to Re: make subroutine that takes expression as implicit block as first arg
in thread make subroutine that takes expression as implicit block as first arg

That won't work, for the proposed case:

Type of arg 1 to main::mygrep must be block or sub {} (not numeric eq +(==)) at /tmp/mygrep line 7, near "10)" Execution of /tmp/mygrep aborted due to compilation errors.

Perhaps something like this?

sub mygrep { my $s = "grep $_[0]"; eval $s; } print for mygrep('$_ % 2 == 0, 0..10'); # :-)

--
"Language shapes the way we think, and determines what we can think about."
-- B. L. Whorf