|The stupid question is the question not asked|
This is a nicely-written program, well done! If the C++ version is up to this standard, you should get high marks on the assignment.
I did notice one logical error:
If the user enters 1/0, this correctly flags division by zero. But,
How to fix this? One way would be to extract the denominator (if any) and test whether that is zero. But this is Perl, so TMTOWTDI.
Now to style: In Perl, it’s better to declare a variable as late as possible in the code. So, looking at this line:
actually only $command needs to be declared before the outer while loop. The rest can safely be declared at the point of first use. (And yes, I would declare $total separately within each of the if / elsif blocks.)
Hope that helps,
In reply to Re: Overloaded operators calling similar functions...