http://www.perlmonks.org?node_id=1072515


in reply to Perl Script for reading a mathematical expression

I happen to have written a module that handles the evaluation of expressions without messing with unsafe solutions such as eval: Math::Expression::Evaluator. It does the hard part of the task for you.