1  print "Enter a temperature (e.g., 32F or 100C):\n";
  2  $input = <STDIN>; chomp( $input );
  3  
  4  if ( $input =~ m/^([-+]?\d+)([CF])$/ ) {
  5    $temp = $1; $type = $2;
  6    if ( $type eq "C" ) {
  7      $celsius = $temp;
  8      $fahrenheit = ( $celsius * 9/5 ) + 32;
  9    } else {
 10      $fahrenheit = $temp;
 11      $celsius = ( $fahrenheit - 32 ) * 5/9;
 12    }
 13    printf "%.2f C = %.2f F\n", $celsius, $fahrenheit;
 14  } else {
 15    print "Expecting a temperature, not \"$input\"\n";
 16  }