use strict; use warnings; my $str = " Hello\n\t\n World \n"; print ">$str<\n"; $str =~ s/\b\s+\b/ /g; print ">$str<\n";