print "Enter a temperature (e.g. 32F 100C):\n"; $input = ; chomp ($input); if ($input =~ m/^([-+]?[0-9]+(\.[0-9]*?)\s*([CF])$/i) { $InputNum = $1; $Type = $2; $type = $3; if ($type eq "C" or $type eq "c") { $C = $InputNum; $F = ($C * 9/5) + 32; } else { $F = $InputNum; $C = ($F -32) * 5/9; } printf"%.2f C = %.2f F\n", $C, $F; } else { print "Expecting a number, so I don't understand \"$input\".\n"; }