in reply to Re: Anonymous subroutines (why and what for)
in thread Anonymous subroutines

I believe this is an excellent summary. Thanks, LanX!

One context in which I've seen anonymous subs used a lot is where you have code chunks being defined within, and called by, a framework. Execution of the code takes the form of eval'ing the code, so it has lexical context just like a sub. If, in such a code chunk, you want to define a sub so you can call it multiple times (or any other reason), you have to do it as an anonymous sub, since you can't do it any other way (at least not without getting a "won't stay shared" warning). (But your other comment is important too.)

  • Comment on Re^2: Anonymous subroutines (why and what for)

Replies are listed 'Best First'.
Re^3: Anonymous subroutines (why and what for)
by LanX (Saint) on Dec 12, 2023 at 00:29 UTC
    Thanks!

    I'm not sure I've ever worked with such kind of a "code template system" ° but I wanted to add metaprogramming anyway. (Done)

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    see Wikisyntax for the Monastery

    °) maybe apart the monastery's codebase ;)

      ;-)