Then you should use a Real Parser to make sense of your expression.
Parse::RecDescent was mentioned and is fine to use, if a little slow. Maybe you want to try this out in Perl 6 Rules though? You'd need Pugs for that, or perhaps stay in Perl 5 and give
Pugs::Compiler::Rule a shot.