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.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Anonymous subroutines (why and what for)
by LanX (Saint) on Dec 12, 2023 at 00:29 UTC | |
by jdporter (Paladin) on Dec 12, 2023 at 18:15 UTC |