in reply to Help with simple calculator script.
add this:
print $greeting; chomp($operator = <STDIN>); #your other prints and stuff here $c = $a - $b if $operator eq "-"; $c = $a * $b if $operator eq "*";
The if statement could also be written as such:
if ($operator eq "-") { $c = $a - $b; } else { $c = $a * $b; }
"Pain is weakness leaving the body, I find myself in pain everyday" -me
|
|---|