Just on a side note, would it not be better to use s/\s//g; or tr/\s//;.
in reply to Craftier
I just did a benchmark on the two and the regex is approx 3 times quicker than the $_ = join ' ', split;
This is the benchmarik that I ran.
and the results are
my $junk = 'The quick brown fox Jumped over the lazy dog';
'split' => '$junk = join \' \',split $junk;',
'regex1' => '$junk =~ tr/\s//;',
'regex2' => '$junk =~ s/\s//g;',
Benchmark: timing 5000000 iterations of regex1, regex2, split...
regex1: 3 wallclock secs ( 4.38 usr + 0.00 sys = 4.38 CPU) @ 11
regex2: 3 wallclock secs ( 3.50 usr + 0.00 sys = 3.50 CPU) @ 14
split: 15 wallclock secs (15.07 usr + 0.00 sys = 15.07 CPU) @ 33