in reply to Nesting Functions
sub outer { my $c_inner = sub { print "perl" }; $c_inner->(); }
Please note that Python is implicitly preferring references while Perl prefers the "Explicit is better than implicit" approach (yes it's ironic)
> Python has Local, Enclosing, Global and Built-in variables.
More or less: *
> It was this video that promoted my thinking on this. https://www.youtube.com/watch?v=QVdf0LgmICw
Not linkified not watched.²
Hint: Please provide code examples if you want better answers.
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
°) There was an experimental attempt to allow "private subs" in Perl, which was essentially syntactic sugar for the following IIRC. No idea if it's still available or deprecated.
*) the py-docs are sparse and incomplete here. Variable declarations in class context become attributes. These are essentially package vars in Perl. (Python has no package and Perl has no class )
²) tried to, but won't watch a 20 min video to guess what your question is.
³) updated, see Re^7: Nesting Functions for details
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Nesting Functions
by choroba (Cardinal) on Jul 19, 2019 at 12:05 UTC | |
by LanX (Saint) on Jul 19, 2019 at 12:23 UTC | |
|
Re^2: Nesting Functions
by Eily (Monsignor) on Jul 19, 2019 at 12:34 UTC | |
by LanX (Saint) on Jul 19, 2019 at 12:46 UTC | |
by Eily (Monsignor) on Jul 19, 2019 at 13:32 UTC | |
by LanX (Saint) on Jul 19, 2019 at 13:48 UTC | |
by choroba (Cardinal) on Jul 19, 2019 at 14:12 UTC | |
| |
by Eily (Monsignor) on Jul 19, 2019 at 14:23 UTC | |
| |
by LanX (Saint) on Jul 19, 2019 at 14:15 UTC |