++ed by:
JKUTEJ

1 PAUSE user

Andrea Pavlovic
and 1 contributors

NAME

Data::Formula - formulas evaluation and calculation

SYNOPSIS

    my $df = Data::Formula->new(
        formula   => 'var212 - var213 * var314 + var354',
    );
    my $val = $df->calculate(
        var212 => 5,
        var213 => 10,
        var314 => 7,
        var354 => 100
    );
    # 5-(10*7)+100

    my $df = Data::Formula->new(
        variables => [qw( var212 var213 n274 n294 var314 var334 var354 var374 var394 )],
        formula   => 'var212 - var213 + var314 * (var354 + var394) - 10',
    );
    my $used_variables = $df->used_variables;
    # [ var212 var213 var314 var354 var394 ]

    my $val = $df->calculate(
        var212 => 5,
        var213 => 10,
        var314 => 2,
        var354 => 3,
        var394 => 9,
    );
    # 5-10+2*(3+9)-10

DESCRIPTION

evaluate and calulate formulas with variables of the type var212 - var213 + var314 * (var354 + var394) - 10

METHODS

new()

Object constructor.

     my $df = Data::Formula->new(
        formula   => 'var212 - var213 * var314 + var354',
     );

used_variables()

return array with variables used in formula

calculate()

evaluate formula with values for variables, returns caluculated value

AUTHOR

Jozef Kutej, <jkutej at cpan.org>

CONTRIBUTORS

The following people have contributed to the File::is by committing their code, sending patches, reporting bugs, asking questions, suggesting useful advises, nitpicking, chatting on IRC or commenting on my blog (in no particular order):

    Andrea Pavlovic

LICENSE AND COPYRIGHT

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.