http://www.perlmonks.org?node_id=1075956


in reply to String regex replacement

What you describe, sounds like rounding down to the next 1000s. Have a look at this example:

use strict; use warnings; my @numbers = ( 500, 988, 1210, 1300, 2134, 2500 ); # rounding numerically for (@numbers) { my $n = int( $_/1000 )*1000; print "$_ => $n\n"; } # rounding in regex for (@numbers) { s{(\d+)}{int( $1/1000 )*1000}e; print "$_\n"; }