Params::CallbacksEnable functions to accept blocking callbacks | |
Download |
Params::Callbacks Ranking & Summary
Advertisement
- License:
- Perl Artistic License
- Price:
- FREE
- Publisher Name:
- Iain Campbell
- Publisher web site:
- http://search.cpan.org/~cpanic/
Params::Callbacks Tags
Params::Callbacks Description
Params::Callbacks is a Perl module that provides the developer with an easy and consistent method for converting a function that returns a result, into a function that will allow its result to pass through one or more blocking callbacks, before it is delivered to the caller.It is up to the function's author to decide how and where in the function's flow those callbacks should be invoked. This is could be important during the creation of sets of results: one could apply the callbacks to a finished set, or apply them to each element of the result set as it is added.SYNOPSIS # Using the object oriented calling style... use Params::Callbacks; sub counted { my ($callbacks, @args) = Params::Callbacks->extract(@_); $callbacks->filter(@args); } my $size = counted 1, 2, 3, sub { print "> $_\n" for @_; return @_; }; print "$size items\n"; # > 1 # > 2 # > 3 # 3 items # Or, just mix-in the "callbacks" function... use Params::Callbacks qw/callbacks/; sub counted { my ($callbacks, @args) = &callbacks; $callbacks->filter(@args); } my $size = counted 'A', 'B', 'C', sub { print "> $_\n" for @_; return @_; }; print "$size items\n"; # > A # > B # > C # 3 itemsProduct's homepage
Params::Callbacks Related Software