Randy Stauner > Sub-Chain-0.012 > Sub::Chain::Named

Download:
Sub-Chain-0.012.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.012   Source  

NAME ^

Sub::Chain::Named - subclass of Sub::Chain with named subs

VERSION ^

version 0.012

SYNOPSIS ^

  my $chain = Sub::Chain::Named->new(subs => {name1 => \&sub1});
  $chain->name_subs(name2 => \&sub2, name3 => \&sub3);

  # ...

  $chain->append($name, \@args, \%opts);

DESCRIPTION ^

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.

METHODS ^

new

  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.

See "new" in Sub::Chain for more information.

append

  $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.

name_subs

  $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).

AUTHOR ^

Randy Stauner <rwstauner@cpan.org>

COPYRIGHT AND LICENSE ^

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.

syntax highlighting: