0
아래 Perl 프로그램에서 어떤 이유로 정수 나누기가 발생하지 않습니다. 대신 콘솔은 두 정수의 concatination을 출력하고 divsion의 if 문도 발생하지 않습니다. 왜 이런거야? 감사.코드에서 Perl과 정수부가 작동하지 않습니다.
코드 :
print "Please Enter Your First Number\n";
$num1 = <>; chomp $num1;
print "Please Enter Your Operation\n";
$operation = <>; chomp $operation;
print "Please Enter Your Second Number\n";
$num2 = <>; chomp $num2;
if ($operation == "+"){
$result = $num1 + $num2;
} elsif ($operation == "-"){
$result = $num1 - $num2;
} elsif ($operation == "*"){
$result = $num1 * $num2;
#Problem HERE:
} elsif ($operation == "/"){
if ($num2 == 0){
print "Cant Divide be Zero Mate\n";
} else {
$result = $num1/$num2;
}
}
print "\n";
print "result of $num1 $operation $num2 = $result";
는 유 예와 함께 제공 할 수있다? – KingMak
오는 문자열 비교를위한 eq이고 숫자 비교를위한 ==입니까? – KingMak
@KingMak 네, 바로 그게 - 문자열의 경우'eq', 숫자의 경우'=='입니다. –