Perlに質問があります。ユーザーに温度を尋ね、次にそれを華氏または華氏に変換するかどうかを尋ねるPerlスクリプトを作成することです。変換を実行し、答えを表示します。温度変換の式は次のとおりです。
1) Celsius to Fahrenheit:C=(F-32) x 5/9
2) Fahrenheit to Celsius:F=9C/5 + 32
私のスクリプトは次のとおりです。
#!/usr/bin/perl
use strict;
use warnings;
print "Enter the temperature: ";
my $temp = <STDIN>;
print "Enter the Conversion to be performed:";
my $conv = <STDIN>;
my $cel;
my $fah;
if ($conv eq 'F-C') {
$cel = ($temp - 32) * 5/9;
print "Temperature from $fah degree Fahrenheit is $cel degree Celsius";
}
if ($conv eq 'C-F') {
$fah = (9 * $temp/5) + 32;
print "Temperature from $cel degree Celsius is $fah degree Fahrenheit";
}
キーボードから$tempと$convを入力すると、空白の出力が表示されます。どこが間違っているのでしょうか。助けてください。前もって感謝します。