use strict; use warnings; while() { chomp; my $old = $_; s/\.(?=.*?\.)/_/g; print "Change: $old to $_\n"; } __END__ test0.file0.new_20060411.zip test1.file1.new_20060411.zip test2.file2.new_20060411.zip test3.file3.new_20060411.zip