Hi again,
Ugh: please ignore my previous example, which split on the empty
string by mistake (it's even evident in the script you quoted).
Thwack...
Let me try and pull this together: splitting on a string containing
a single space is special in a "do what you probably mean" way: it's
not the same as splitting on \s+, in that the former discards leading
and trailing horizontal white space (ie, spaces or tabs).
So if we have
#!/usr/bin/perl
use warnings;
use strict;
my $string = " \t1 2\t 3\t\t4\t ";
print join("**", split(" ",$string)),"the end";
print "\n";
print join("**",split(/\s+/,$string)),"the end";
Produces the following output:
1**2**3**4the end
**1**2**3**4the end
In general: when using any regexp as the first argument the split
function acts very much by the book.
Cheers,
Paul