To retain external white space while collapsing internal white space:
use strict; use warnings; my $str = " Hello\n\t\n World \n"; print ">$str<\n"; $str =~ s/\b\s+\b/ /g; print ">$str<\n";
Prints:
> Hello World < > Hello World <
In reply to Re: How to remove \n between two words but retain one space
by GrandFather
in thread How to remove \n between two words but retain one space
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |