Others have noted the approach of join-ing a list of strings with a space and then taking spaces out of the string where appropriate. Conceptually, the other approach is to not put in a space in the first place. See List::Util::reduce().