Re: Split function



On Oct 30, 1:30 pm, rob.di...@xxxxxxx (Rob Dixon) wrote:
Paul Lalli wrote:
Annoyingly, split / /, $foo; and split ' ', $foo; are not the same
thing. split ' ', $foo is a special case that means to split on all
sequences of whitespace. It means the same thing as split /\s+/,
$foo;

Not quite Paul. From perldoc -f split:

A "split" on "/\s+/" is like a "split(' ')" except that any leading
whitespace produces a null first field.

so ' ' splits at the same places as /\s+/, but also omits any leading
empty fields that would result.

Good point. Thanks for the correction.

Paul Lalli

.



Relevant Pages