Edward Baudrez > PDL-NDBin-0.008-TRIAL > PDL::NDBin::Action::CodeRef

Download:
PDL-NDBin-0.008-TRIAL.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  1
View/Report Bugs
Module Version: 0.008   Source   Latest Release: PDL-NDBin-0.015

NAME ^

PDL::NDBin::Action::CodeRef - Action for PDL::NDBin that calls user sub

VERSION ^

version 0.008

DESCRIPTION ^

This class implements a special action for PDL::NDBin that is actually a wrapper around a user-defined function. This class exists just to fit user-defined subroutines in the same framework as the other actions, which are defined by classes (so that the user doesn't have to define a full-blown class just to implement an action).

METHODS ^

new()

        my $instance = PDL::NDBin::Action::CodeRef->new( $N, $coderef );

Construct an instance for this action. Requires two parameters:

$N

The number of bins.

$coderef

A reference to an anonymous or named subroutine that implements the real action.

process()

        $instance->process( $iter );

Run the action with the given iterator $iter. This action cannot assume that all bins can be computed at once, and will not deactivate the variable. This means that process() will need to be called for every bin.

Note that process() does not trap exceptions. The user-supplied subroutine should be wrapped in an eval block if the rest of the code should be protected from exceptions raised inside the subroutine.

result()

        my $result = $instance->result;

Return the result of the computation.

AUTHOR ^

Edward Baudrez <ebaudrez@cpan.org>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2013 by Edward Baudrez.

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: