Next: Text::Wigwam::Library::Procedure | Previous: Text::Wigwam::Library::Iterators | [Table of Contents] | [Text::Wigwam Index] |
Text::Wigwam::Library::Math #abs, #add, #dec, #decr, #div, #inc, #incr, #int, #mod, #mult, #random, #sub
This library provides directives which are useful for calculating values.
The directives within this library can be imported into specific branches of
the directive tree (which transcends from Text::Wigwam::Directives
) via
plug-ins or modules using one of the following techniques.
package Text::Wigwam::Directives::some::arbitrary::branch; # import everything use Text::Wigwam::Library::Math qw/:all/; package Text::Wigwam::Directives::another::arbitrary::branch; # import selectively use Text::Wigwam::Library::Math( qw/ :abs :add :dec :decr :div :inc :incr :int :mod :mult :random :sub / );
Returns the absolute (positive) form of numeric value num.
[!! #abs -123 /* output: 123 */ !!]
Returns the sum of numeric values num1 and num2.
[!! #add 1 2 /* output: 3 */ !!]
Decrements a variable's value by 1 and returns nothing.
[!! #define var 5 #dec var "var is " var /* output: var is 4 */ !!]
Decrements a variable's value by 1 and returns the new value.
Returns the result of num1 divided by num2.
[!! #div 27 9 /* output: 3 */ !!]
The #div
directive is susceptible to divide by zero exceptions. If
num2 is zero, this will halt global processing of all templates.
Increments the value of var by 1 and returns nothing.
[!! #define var 1 #inc var "var is " var /* output: var is 2 */ !!]
Increments the value of var and returns the new value.
Returns the integer value of num.
[!! #int 12.99 /* output: 12 */ !!]
Returns the modulus of num1 and num2.
[!! #mod 9 7 /* output: 2 */ !!]
If num2 is zero, a divide by zero exception will be thrown.
Returns the product of num1 and num2.
[!! #mult 25 4 /* output: 100 */ !!]
Returns a random integer ranging from num1 to num2.
[!! #define die1 #random 1 6 #define die2 #random 1 6 "You rolled " #add die1 die2 " (" die1 " & " die2 ")" !!]
Returns the resulting value of num1 minus num2.
[!! #sub 27 9 /* output: 18 */ !!]