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


in reply to Re: Replacing multiple spaces into one character?
in thread Replacing multiple spaces into one character?

you could also use the magical ' ' (single space) arg to split, which will remove leading spaces as well...
#!/usr/bin/perl -wT use strict; my $str =' Perlmonks is a very cool place '; $str = join '_', split ' ', $str; print $str, "\n"; =OUTPUT Perlmonks_is_a_very_cool_place

-Blake