in reply to Solving an expression

If it's valid Perl code, you can use eval to evaluate its result. (But note that eval can execute arbitrary code, so you should make sure there are no system calls or other evil things in the string).

There are also modules that execute arithmetic expressions. For example I wrote Math::Expression::Evaluator some time ago, which handles the arithmetic, but iirc not the comparisons. Other modules in the Math:: namespace might do that, though.

Replies are listed 'Best First'.
Re^2: Solving an expression
by Jenda (Abbot) on Jun 13, 2009 at 16:16 UTC

    It's probably a bit safer to use Safe instead of plain old eval"".

    Jenda
    Enoch was right!
    Enjoy the last years of Rome.

      If i know wat operator to use only then i can use eval rit. Everything is randomly generated. The expression will go as input to the module which inturn evaluates this expr and returns the result.