$str =' Perlmonks is a very cool place '; $str = join '_', split /\s+/, $str; print $str;