in reply to Perl and maths

I think that, I know what you are after. It would be fun to see math equations solved step by step automatically. Your input is an equation and as output you want to get step by step answers. You need to define the steps and precedence. In the case you have presented, for example, you might want to do cross multiplication of the numbers within the parantheis and then remove the paranthesis and make it more simple before getting the final answer. It would be fun to define all these rules for different equations. Once you do that, you will have better control of working of math euqation and will serve a useful aid in your teaching.

For coding these, you may define each element as a seperate entitiy in your euqation. Parse::RecDescent would be very useful for this. Once you have elements and their positions within equation, you may apply your rules to create the next step and so on.