i think i would start with creating a module for fractions, with, and probably with a function that does all of the operations of fractions (add, subtract...). maybe you'll have to make it output the common denominator step inside the module though. so then you have something like ($frac1 + $frac2) / ($frac3 + $frac4) where $frac\d is of the type of your new fraction module. and then you might end up with another fraction... where $new_fraction's numerator is ($frac1 + $frac2) and it's denominator is ($frac3 + $frac4).
so (obvioulsy implementation is up to you) i would think of something a data structure for fraction as a hash with numerator and denominator, and your $new_fraction would be something like:
$new_frac => {
numerator => "5/3 + 7/13",
denominator => "5/2 - 3/7"
}
and then eventually something like
$new_frac => {
numerator => {
numerator => 86,
denominator => 39
},
denominator => {
numerator => 29,
denominator => 14
}
}
come to think of it, you may need to have a data structure or module to represent an "expression" too.
also, to parse the expression, you may want to look at postfix (although you can certainly still output the expressions in infix)
these are just my thoughts on how i'd approach it.