in reply to Re: split and capture some of the separators
in thread split and capture some of the separators

grep $_,
will erase some tokens such as 0. Better to use
grep length($_),
or
grep { defined($_) && length($_) }

Replies are listed 'Best First'.
Re^3: split and capture some of the separators
by BrowserUk (Patriarch) on Oct 07, 2004 at 22:29 UTC

    T'is a good point in the general case.

    What about just

    grep length, split...

    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon
      If $_ is undef, you get the:
      Use of uninitialized value...

        Okay, same point though.

        grep{ defined && length } split ...;

        Examine what is said, not who speaks.
        "Efficiency is intelligent laziness." -David Dunham
        "Think for yourself!" - Abigail
        "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon