The difference between any two numbers (where one is the mirror of the other) will always be a multiple of 9. By a clever trick of math, this means adding up all of the digits should always get you 9. Since you dropped a digit early on, all you have to do is subtract 9 from your result and you've got the original number.
I'm not sure what you mean by a "mathematical reverse", but the reverse function should neatly swap things around for you.
print scalar reverse 12345; # 54321