use strict; use warnings; use constant TO_US => 0.127; while () { s/(\d+.\d+)/convert($1)/eg; print; } sub convert { return sprintf "%.2f", $_[0] * TO_US; } __DATA__ Hello all! Today I bought breakfast for 02.50 and lunch for 10.20 Dinner was a real splurge at 21.00.