The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Getopt::EX::RPN - RPN calculation module for Getopt::EX command option

SYNOPSIS

use Getopt::EX::RPN qw(rpn_calc);

DESCRIPTION

Getopt::EX::RPN is a wrapper for Math::RPN package which implement Reverse Polish Notation calculation. rpn_calc function in this package takes additional HEIGHT and WIDTH token which describe terminal height and width.

rpn_calc recognize following tokens (case-insensitive) and numbers, and ignore anything else. So you can use any other character as a delimiter. Delimiter is not necessary if token boundary is clear.

HEIGHT  WIDTH
{   }
+,ADD  ++,INCR  -,SUB  --,DECR  *,MUL  /,DIV  %,MOD  POW  SQRT
SIN  COS  TAN
LOG  EXP
ABS  INT
&,AND  |,OR  !,NOT  XOR  ~
<,LT  <=,LE  =,==,EQ  >,GT  >=,GE  !=,NE
IF
DUP  EXCH  POP
MIN  MAX
TIME
RAND  LRAND

Since module Getopt::EX::Func uses comma to separate parameters, you can't use comma as a token separator in RPN expression. This package accept expression like this:

&set(width=WIDTH:2/,height=HEIGHT:DUP:2%-2/)

AUTHOR

Kazumasa Utashiro

LICENSE

Copyright Kazumasa Utashiro.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.