in reply to Chomp a numerical expression, return the answer.
Try this:
UPDATE: As blazar points out, while this code does what you want, know that it will blissfully run any valid Perl command. You might add some editing of your input before handing it to eval.chomp($exp = <STDIN>); $out = eval $exp; print $out, "\n";
Good Luck,
Trix
|
---|
In Section
Seekers of Perl Wisdom