Re: Split function



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.

Rob

.



Relevant Pages

  • Re: Split function
    ... $foo is a special case that means to split on all ... whitespace produces a null first field. ... Paul Lalli ...
    (perl.beginners)
  • Re: while read and whitespace problem.
    ... You can always turn off wildcards. ... > foo a"a bar ... 'first field' 2 'third field' ...
    (comp.unix.shell)
  • CodingStyle: mention bitfields/whitespace style, prefer (!foo) in examples
    ... Mention whitespace and bitfields style, prefer (!foo) to ... Get a decent editor and don't leave whitespace at the end of lines. ... +Do not put whitespace between any of the unary operators and their operand. ...
    (Linux-Kernel)
  • Re: Comments requested: brief summary of C
    ... >> ``C treats all blanks space as equivalent, ... >> and indents are for readability only.'' ... > space or whitespace, with no comparand this ... > #define FOO ...
    (comp.lang.c)
  • Re: Comments requested: brief summary of C
    ... >> can only be read as meaning one whitespace is equivalent to another ... >> is not reasonable to read it as saying whitespace is equivalent to an ... FOO and 10 isn't the same as a newline between FOO and 10 ... "the large print giveth, and the small print taketh away" Tom Waits - Step right up ...
    (comp.lang.c)