If the above posters have convinced you that you don't want to use eval, you might take a look at the guts of HTML::Template::Expr. It implements a little expression language using Parse::RecDescent. You could take the parser and execution engine and cut it down to whatever sub-set makes sense for your problem.