in reply to make subroutine that takes expression as implicit block as first arg
You can accomplish your task using Prototypes. In fact, from the linked documentation,
here's a reimplementation of the Perl grep operator:sub mygrep (&@) { my $code = shift; my @result; foreach $_ (@_) { push(@result, $_) if &$code; } @result; }
Update: Your example would be called as: print join ",", mygrep {$_ % 2 == 0} 0..10; Note the deviation from the proposed use case. I'd initially missed the spec for "automatically put [ting] it in an implicit block"
In Section
Seekers of Perl Wisdom