This one involves a bit of magic, but it does not use eval, nor does it explicitly list the four operators.
use Math::BigFloat; $big = Math::BigFloat->bzero; $Problem = "12 - 5"; $Problem =~ /^(\d+)\s(\S)\s(\d+)$/; ($Number1, $Operator, $Number2) = +($1, $2, $3); $Answer = ($big + $Number1)->${\("(" . $Operator)}($Number2); print $Answer, "\n";
In reply to Re: '+' to +
by ambrus
in thread '+' to +
by NateTut
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |