Or use the Safe module and mask the operators that can be considered potentially harmful. This has the benefit of allowing the "math expression" to be arbitrarily complex (Perl, really), and if you pre-loaded things like Math::Complex, you could potentially have a very powerful "calculator."