I'd be wary of where your input is coming from. If it's user supplied and you use eval(), they can type any command in there with potentially disasterous results. If you go this route, you want to check out
Safe.
You might find the snippet at
Evaluate Expressions. does the trick. There are also modules on CPAN. Look for the term Expression as I can't recall the names off the top of my head.
-Lee
"To be civilized is to deny one's nature."