use strict; use warnings; # From http://prometheus.frii.com/%7Egnat/yapc/2000-stages/slide31.html # Fixed a typo in the regex (Nathan forgot to escape the forwardslash.) while () { chomp; my $celsius = my $fahrenheit = $_; #was $fahrenheit =~ s|(\d+)C|($1*9/5)+32 . "F"|ge; $fahrenheit =~ s|(\d+\.\d+)C|($1*9/5)+32 . "F"|ge; print "$celsius is $fahrenheit\n"; } #Outputs: #12C is 12C #16.5C is 61.7F #-40C is -40C __DATA__ 12C 16.5C -40C