note tsee <p>I forgot to mention how you'd actually use that specific "wheel" to evaluate expressions. I know it's not the point of this meditation to just use the existing tools, but comparison might still be sensible.</p> <code> #!/usr/bin/perl use strict; use warnings; use Math::Symbolic; my $parser = Math::Symbolic::Parser->new(); while (1) { print "\n> "; my $line = <STDIN>; my $tree = $parser->parse($line); print("Parse error.\n"), next if not defined $tree; print "Entered: $tree\n"; my $result = $tree->value(); print("Evaluation error.\n"), next if not defined $result; print "Result: $result\n"; } </code> <p>The output would look like this:</p> <code> > 3*4.2e3+5^(3.1+2) Entered: (3 * 4.2e3) + (5 ^ (3.1 + 2)) Result: 16270.6841971501 > a*b+c Entered: (a * b) + c Evaluation error. </code> <p>That last bit shows that the parser is actually intended to be used with variables, too. So it's not a parse error but an evaluation error.</p> <p>Switching to using the YAPP based parser is rather straightforward, too. Just add "implementation =&gt; 'Yapp'" to the call to the constructor.</p> <p>Cheers,<br/>Steffen</p> 624445 624473