#!c:\perl\bin\perl.exe -w use strict; use warnings; for my $line () { $line =~ s/ \d{4,}( |$)/ 0$1/g; print $line; } __DATA__ 1125356700 0 0 0 0 1125356400 15 0 25 0 1125356100 25 0 25 0 1125355800 25 0 25 0 1125355500 25 0 25 0 1125397800 0 0 0 0 1125397500 0 0 0 0 1125397200 0 0 0 0 1125396900 0 0 0 0 1125396600 0 0 0 0 1125396300 0 0 0 0 1125396000 39006 0 63597 0 1125395700 63597 0 63597 0 1125395400 63597 0 63597 0 1125395100 63597 0 63597 0 1125394800 63597 0 63597 0 1125394500 63597 0 63597 0 1125394200 63597 0 63597 0 #### perl.exe -ple "s/ \d{4,}( |$)/ 0$1/g" filename #### $line =~ s/ (\d+)/$1>1000?" 0":" $1"/ge;