How many km in a marathon?

How many km in a marathon?
Here you go.
#!perl
my $sentence = 'A marathon is 26.2 miles.';
$sentence =~ s! # substitution \b((?:\d+)?(?:\.\d+)?)\b # find a number \s+ # followed by space (kilometer|mile)s? # "km"s or "m"s ! # sprintf "%.1f %s%s", # convert, $1 * ($2eq'mile'?1.609:.6214), # "m"s, use 1.609 ($2eq'mile'?'kilometer':'mile'), # "km"s, use .6214 ($1*($2eq'mile'?1.609:.6214))==1? # the math '' : 's' # pluralize or not !xeg; #
print $sentence, "\n";
[close] Permanent link · http://querylog.com/q/How+many+km+in+a+marathon%3F

Suggested HTML for linking:
Link preview: How many km in a marathon?
14 August 2005 · Ps & Qs
Browse by the page—15 Q&R each
« previous | more »