Perl: the Markov chain saw | |
PerlMonks |
Re: Generate a truth table from input stringby psini (Deacon) |
on May 13, 2008 at 15:09 UTC ( [id://686291]=note: print w/replies, xml ) | Need Help?? |
Quick&dirty solution: Use a regualr expression to extract all the variables (assuming a form of \w+), store them in an hash along with an auto-generated variable name (eg $a,$b..). Use another regexp to replace all variables with the new names and replace the operators with the corresponding perl operator (eg s/\*/ && /g). Perform a series of nested loops, one for each variable, and eval the expression. Note that this is probably not what your teacher wants from you!
Rule One: Do not act incautiously when confronting a little bald wrinkly smiling man.
In Section
Seekers of Perl Wisdom
|
|