# input num1 # input num2 # First, setup a hash that defines what's can be done and it's attributes. my %ops = ( '+' => { label => 'Sum' }, '-' => { label => 'Difference' }, '*' => { label => 'Product' }, '/' => { label => 'Division' }, 'M' => { label => 'Multiplication', table => 1, op => '*' }, ); while (1){ #adding a loop around this # using a here-doc to do the output print <); last if exists $ops{$sign}; # see if we got something that we configured in the hash } my $op = $ops{$sign}; if( $op->{table} ){ printf "the %s Table For %d and %d is \n", $op->{label}, $num1, $num2; printf("%d %s %d = %f\n", $_, $op->{label}, $num1, eval($_.$op->{op}.$num1) ) for 1 ..$num2; }else{ printf "The %s of the Numbers %d %s %d is %f\n", $op->{label}, $num1, $sign, $num2, eval "$num1 $sign $num2", ; }