in reply to '+' to +
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";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: '+' to +
by ambrus (Abbot) on May 30, 2005 at 20:54 UTC |