$text = "U.S. Army\nthe Army has been berry-berry good to me\nUS-Army\nUS Army\n"; $text =~ s/\bArmy\b|U\.S\. Army/US-Army/g; #### US-Army the US-Army has been berry-berry good to me US-US-Army US US-Army #### while ($text =~ s/\bArmy\b|U\.S\. Army/US-Army/g) { print "$text\n\n"; }