in reply to execute a string

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