![]() |
|
Perl Monk, Perl Meditation | |
PerlMonks |
make subroutine that takes expression as implicit block as first argby myuserid7 (Scribe) |
on Aug 13, 2010 at 19:42 UTC ( #854993=perlquestion: print w/replies, xml ) | Need Help?? |
myuserid7 has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I want to make my own subroutine work like grep() or map(), being able to take either a block or an expression as a first argument; and if an expression is given, automatically put an it in an implicit block, just like grep() and map() does
The block part is easy; but is it possible to make it do the expression part?
For example, how to define mygrep(), such that I can do
just like I can do
Back to
Seekers of Perl Wisdom
|
|