s/(\d+\.\d+\.\d+\.)(\d+)/$1.($2-1)/e; # or (just to show another variant) s/(\d+\.\d+\.\d+\.)(\d+)/"$1".($2-1)/e;