in reply to Re^3: Array ending up empty when processing more than a single file
in thread Array ending up empty when processing more than a single file
Named subs are defined at compile time, that's why you can call a sub which is defined later.
A closure can only "share" the set of closed over variables it sees at definition time.
(i.e. name and reference are added to the "lexical pad" compare PadWalker)
That's why nesting named subs are discouraged in Perl.
But when using an anonymous sub, the definition happens at run time.
something like
*name = sub {...} would solve this.
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Array ending up empty when processing more than a single file
by Your Mother (Archbishop) on Oct 05, 2017 at 18:01 UTC | |
|
Re^5: Array ending up empty when processing more than a single file
by Eily (Monsignor) on Oct 06, 2017 at 01:36 UTC | |
by LanX (Saint) on Oct 06, 2017 at 01:57 UTC | |
by Eily (Monsignor) on Oct 06, 2017 at 08:10 UTC | |
by LanX (Saint) on Oct 06, 2017 at 08:59 UTC |