Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • You can omit the sub keyword only when the closure is the first thing in the parameter list.

    The usual workaround is a do-nothing function with only the closure as prototyped parameter:

    sub as(&;*) { @_ }

    Then you can say

    describe $foo as { $bar + $baz };

    or whatever. Though this is questionable in the sense that it has to be looked up in the documentation, whereas the not-so-pretty solution is plainly obvious to anyone who knows enough Perl.