good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: Ruby: An Abbot breaks silencewindby John M. Dlugosz (Monsignor) |
on Jun 13, 2001 at 00:12 UTC ( [id://87922]=note: print w/replies, xml ) | Need Help?? |
For grins, I tried converting this example from the reference from Ruby to Perl.
After all, the oft-touted ability to pass blocks as parameters is something Perl does, too. With the prototype syntax, it should be just as simple, right? Well, this brings me to my own Meditation. My first try didn't take. Browsing the perlsub page, I find, “An & requires an anonymous subroutine, which, if passed as the first argument, does not require the sub keyword or a subsequent comma.” So, I need to reverse the order of the arguments. Passing a sub last would require a sub keyword in the call. Why is this so? Meanwhile, it doesn't work for methods, so you can't really use the prototypes to give rise to this syntax for general-purpose iterators (that are part of a collection). —John
In Section
Meditations
|
|