Sub::Chain::Named - subclass of Sub::Chain with named subs
version 0.012
my $chain = Sub::Chain::Named->new(subs => {name1 => \&sub1}); $chain->name_subs(name2 => \&sub2, name3 => \&sub3); # ... $chain->append($name, \@args, \%opts);
This is a subclass of Sub::Chain. It stores a list of named subs and then accepts the name as an argument to "append" (instead of the coderef).
This can simplify things if, for example, you are taking the list of subs dynamically from file input.
my $chain = Sub::Chain::Named->new( subs => { action => sub {}, } );
Instantiate a Sub::Chain instance with a collection of named subs.
A hashref of name => \&sub pairs can be passed as the subs option.
name => \&sub
subs
See "new" in Sub::Chain for more information.
$named->append($sub_name); $named->append($sub_name, \@args, \%opts);
Just like "append" in Sub::Chain except that $sub_name is a string which is converted to the corresponding sub and then passed to "append" in Sub::Chain.
$sub_name
$named->name_subs(goober => \&peant_butter);
Add named subs to the collection. Takes a hash (or hashref), or just a single name and a value (a small hash).
Randy Stauner <rwstauner@cpan.org>
This software is copyright (c) 2010 by Randy Stauner.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Sub::Chain, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Sub::Chain
CPAN shell
perl -MCPAN -e shell install Sub::Chain
For more information on module installation, please visit the detailed CPAN module installation guide.