in reply to Re^3: $_ functions vs argument-using functions
in thread $_ functions vs argument-using functions

Yeah. These magic parsing exceptions are clearly not accessible to normal users, especially since the perldoc page doesn't seem to document it at all. How was I supposed to find out about this exception reading the docs?

In any case, I cannot include a large amount of code in an anonymous block passed to map(). So I guess this sanctions the use of $_-using functions.

  • Comment on Re^4: $_ functions vs argument-using functions

Replies are listed 'Best First'.
Re^5: $_ functions vs argument-using functions
by LanX (Saint) on Sep 09, 2013 at 19:31 UTC
    It's documented, see perlglossary for "expression".

    The point is you can't reuse this coding style very often, so better avoid it.

    You can write sub func (&@) { } to use block syntax. like in func {shift()+1 } 1..10

    Or you can directly pass function references  f(\&g(\&h),1..10)

    or anonymous subs  f(sub {...},1..10)

    without using prototypes at all.

    But Perl won't allow you to rewrite anything like func EXPR, LIST acting like map does.

    And as I said have a look into HOP.

    Please understand that I won't go further into details of a theoretical discussion, I'd rather prefer to see a real use case from you such that we can recommend the Perl way to do it.

    Cheers Rolf

    ( addicted to the Perl Programming Language)