in reply to Local Subroutines
A code reference can be assigned to a local or lexical (my) variable. Named subs are always package global.
Here is a sub which takes a list of code references and returns a coderef to a function which executes them in order on @_.
That's not necessarily a design you'd want, but it illustrates the syntax. The weaknesses include implied strong coupling between subs you'd list in the codestick call through their need to cooperate over @_.# Usage: my $code = codestick( \&foo, \&bar, \&baz); # Call with $code->(LIST); sub codestick { my @subs = @_; sub { &$_ for @subs; } }
After Compline,
Zaxo
|
|---|