That's what eval does. Be careful with it though, as it can execute any code, so you should be cautious with user input ;-)
Nb: try print $toCalc,, you'll notice that $x as already been replaced by its value. Maybe that's not what you wanted to do. Use simple quotes instead of double ones in your don't want $x to be interpolated
In reply to Re: execute a string
by Eily
in thread execute a string
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |