http://qs321.pair.com?node_id=117756


in reply to Replacing multiple spaces into one character?

1 while $str =~ s/[ ]+/_/;
will also work for this one, it's similar to the /g modifier except that it re-evaluates the entire string after every substitution. But this is for entertainment TIMTOWTDI value only cause something like this
1 while $str =~ s/[ ]+/ _ /;
will just keep running forever as it tries to replace the spaces it creates.