$_ = "mypic.jpg.jpg"; /^(.*)\./s and substr($_, 0, $+[1])=~s/\./_/g; print $_, $/;