I moved some stuff around:
print "put in the name please:";
$login = <stdin>;
chomp ($login);
while ($login ne adam) {
print "put in the name please";
$login = <stdin>;
chomp ($login);
}
print "what do you want to do";
$choice eq <stdin>;
chomp ($choice);
if ($choice = 'divide') { ÷
} else { &add; #instead of if($choice ne 'divide') because you just did that test in a positive manner
}
sub divide {
print "this will divide any two numbers";
print "put in two numbers";
$divide = <stdin>;
$divide2 = <stdin>;
$divide3 = $divide/$divide2;
print "this is the answer";
print $divide3;
}
sub add {
print "this will add any numbers";
$add = <stdin>;
$add2 = <stdin>;
$add3 = $add + $add2;
print "$add3 is the answer"; #compress this because there's no need for 2 print statements here.
}
- print "put in the name please:";
- $login = <stdin>;
- chomp ($login);
- while ($login ne adam) {
- print "put in the name please";
- $login = <stdin>;
- chomp ($login);
- }
- print "what do you want to do";
- $choice eq <stdin>;
- chomp ($choice);
- if ($choice = 'divide') { ÷
- } else { &add; #instead of if($choice ne 'divide') because you just did that test in a positive manner
- }
- sub divide {
- print "this will divide any two numbers";
- print "put in two numbers";
- $divide = <stdin>;
- $divide2 = <stdin>;
- $divide3 = $divide/$divide2;
- print "this is the answer";
- print $divide3;
- }
- sub add {
- print "this will add any numbers";
- $add = <stdin>;
- $add2 = <stdin>;
- $add3 = $add + $add2;
- print "$add3 is the answer"; #compress this because there's no need for 2 print statements here.
- }
The real culprit for the error however, was probably the missing semicolon after the line that reads:
&add if ($choice ne divide)
but we eliminated that line anyway with our new if/else statement