$string =~ s/(\w\w\w)(?!$)/$1-/g; from McA s/(\w{3})\B/$1-/g from Ken