in reply to Re: command interpreter
in thread command interpreter

The easy way to fake a command interpreter is to reuse an existing command interpreter. The one command interpreter you have at hand is Perl, and Perl has the eval statement, which gives you the whole Perl interpreter to use.

So one approach would be to take your command language and convert it into a Perl program. If you give your command language enough thought beforehand, this can be done by something as simple as Filter::Simple, just like Querylet does, or maybe Filter::QuasiQuote, if you don't mind the wrapper of your program looking like Perl.

The following is a simple interpreter for arithmetic expressions, as long as they are on one line:

use strict; while (<>) { my $res = eval $_; if (my $err = $@) { warn "Error: $@"; } else { print "'$_' gives $res\n" }; };