On 2002.01.18 23:13 Jonathan E. Paton wrote: > > For those who haven't met RPN, or are looking for a Perlish > impliementation here is a better (working) one than I > posted earlier: [...]
Just because it's fun, here's a very basic and short command-line RPN evaluator : #!/usr/bin/perl -lw "@ARGV"=~m{^(p(?{print$s[-1]})|(\d+)(?{push@s,$2})|([+-/*])(?{eval "\$s[-2]$3=pop\@s"})|\s)*$}g||die"Syntax error\n"; __END__ It does only +, -, *, / and p(rint), but it may be extended quite easily (at the expense of its conciseness).