Infix to postfix and postfix calculator in Ruby and Perl