perl -pi -e 'BEGIN { %s = map { $_ => [stat $_] } @ARGV} s/foo/bar/g; END { for $f (keys %s) { utime(@{ $s{$f} }[8,9], $f) } }' [files]