$first=; $second=; $operator=; chomp $first; chomp $second; chomp $operator; $expression = "$first $operator $second"; print "$expression:\n"; $result = eval $expression; if ($@) # ($@ is set by eval if something went wrong) { print "oh no!: $@\n"; } else { print "$result\n"; }