use strict; use warnings; while (1) { print "\nEnter a number to add or multiply or nothing to exit: "; my $first = ; chomp $first; last if 0 == length $first; print "Enter a second number: "; my $second = ; chomp $second; print "Enter the operator (+ or *): "; my $op = ; chomp $op; if ($op =~ /^[+*]$/) {print "$first $op $second = " . eval ("$first $op $second") . "\n";} else { print "$op is neither + nor *.\n"; next; } }