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