DR::Money - module to manipulate by money in perl scripts
my $m = Money(2.3); print $m; # prints 2.30 $m += 2.3; # 4.60 $m += Money(4.2); # 8.80
The module supports negative moneys.
Functional constructor.
my $money = Money(0.1); printf '%s', $money; # prints 0.10
Class or instance's method. Construct new instance.
Returns value (string).
my $money = Money(0.1); $v = $money->value; # 0.10 $v = "$money"; # the same
Private method. Assigns new value to instance. Returns instance.
my $money = Money(0.1); $money->_assign( 0.2 ); $money = 0.2; # the same
Private method. Compares two instances as string.
my $money1 = Money(0.1); my $money2 = Money(0.01); $money1->_cmp($money2); $money1 cmp $money2; # the same
Private method. Compares two instances as digit.
my $money1 = Money(0.1); my $money2 = Money(0.01); $money1->_dcmp($money2); $money1 <=> $money2; # the same
Private method. Add two instances (or instance and number).
my $money1 = Money(1.23); my $money2 = Money(2.34); my $money3 = $money1->_add($money2); $money3 = $money1 + $money2; # the same
Private method. Multiplicate money to number
my $money = Money(1.23); $money = $money->_mul(234); $money = $money * 234; # the same
Private method. Substract money.
my $money = Money(1.23); $money = $money->_sub(1.22); $money = $money - 1.22; # the same
Private method. Divide money.
my $money = Money(1.22); $money = $money / 2; $number = $money / Money(2.54); $number = 1.23 / $money;
Private method. Increment money.
my $money = Money(1.22); $money->_inc; # 1.23 $money++; # the same
Private method. Decrement money.
my $money = Money(2.54); $money->_dec; # 2.53 $money--; # the same
Private method. Add value to money.
$money->_addself(23); $money += 23; # the same
Private method. Mull value to money.
$money->_mulself(23); $money *= 23; # the same
Private method. Substract value from money.
$money->_subself(12.34); $money -= 12.34; # the same
Private method. Divide value by number.
Private method. my $money = Money(100.11); my $r = $money->_int; # 100 my $r = int Money; # the same
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available
To install DR::Money, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DR::Money
CPAN shell
perl -MCPAN -e shell install DR::Money
For more information on module installation, please visit the detailed CPAN module installation guide.