PNI::Node - is a basic unit of code
# Create a node in a scenario. use PNI; my $scenario = PNI::scen; my $node = $scenario->add_node( type => 'Foo::Bar' ); # Decorate node, add an input and an output. my $in = $node->in('lead'); my $out = $node->out('gold'); # Fill input data. $in->data('1Kg'); # Produce something. $node->task; # Get output data. my $gold = $out->data;
$node->father;
Returns father scenario.
father
$node->in('input_name');
Creates an input by the given name if such input does not exists.
my $in = $node->in('input_name');
Returns a PNI::In object.
$node->in->data(1); say $node->in->data;
Default input name is 'in', so you can be lazy.
$node->in(1); $node->in('in1'); # idem
If you pass digit x as input_name, it will be replaced by inx.
x
inx
$node->task if $node->is_on;
$node->off;
Turn off a node if something is wrong.
sub task { my $self = shift; # if "in" is not defined, return and turn off the node. $self->in->is_defined or return $self->off; }
$node->out('output_name');
Creates an output by the given name if such output does not exists.
my $out = $node->out('output_name');
Returns a PNI::Out object.
$node->out->data(1); say $node->out->data;
Default output name is 'out', so you can be lazy.
$node->out(1); $node->out('out1'); # ditto
If you pass digit x as output_name, it will be replaced by outx.
outx
my @parents = $node->parents;
Returns the list of nodes which outputs are connected to the node inputs.
To install PNI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PNI
CPAN shell
perl -MCPAN -e shell install PNI
For more information on module installation, please visit the detailed CPAN module installation guide.