#from Anonymous Monk code
> my %allowed = qw{ ( ( ) ) ! !! & && };
> my $finalExpr = map { $allowed{$_} || die "not allowed '$_'" } split
+ '', $expr;
The %allowed hash doesn't look right and it isn't, among other things because it forgets digits [0-9]. A solution along these lines might do something like using taint mode for the script and then:
print "EXPR = ",$newExpr,"\n";
# don't know how to execute shell commands without [A-Za-z] letters
$newExpr =~ /^([\d\s()&|!]+)$/;
printf "%b\n", eval $1;
}
|