$s = 'alter string-N-U-M-B-E-R-O-N-E and string-N-U-M-B-E-R-T-W-O.'; $s =~ s/(\S+([[:upper:]]-){2,}[[:upper:]]\b)/%$1/g; print "$s\n";