in reply to Re: Deleting intermediate whitespaces, but leaving one behind each word
in thread Deleting intermediate whitespaces, but leaving one behind each word
definitely better than any solution using split and joinWell, the best solutions are the ones you understand the most. I doubt there's a performance issue here anyway. So ++ for giving a solution based on the original one.
NB: split /\s+/, $CPU can be written split " ", $CPU since the latter will be translated to the former, as explained in the doc. Then if you don't need the temp variable:
my $result = join " ", split " ", $CPU;
(Okay, maybe in that case using /\s+/ makes it look a little less silly :P)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Deleting intermediate whitespaces, but leaving one behind each word
by Laurent_R (Canon) on Dec 05, 2017 at 11:10 UTC |