in reply to A question on splitting

This is almost certainly the roundabout way of doing this, but you should be able to achieve your result by replacing (s///) the commas without spaces after them with something that does not occur in your dataset, like a tilde ~, for instance. Then you can split on the tilde.

Update: While this would work, it is really a silly answer. As another poster has indicated, there is a reason why you put your split argument inside of //, and that's that it's a regular expression. (I think that using quotes suppresses regular expression processing in split, though.)

Replies are listed 'Best First'.
Re: Re: A question on splitting
by ysth (Canon) on Jan 14, 2004 at 21:08 UTC
    I think that using quotes suppresses regular expression processing in split, though.)
    Nope:
    $ perl -wle'print for split "b+", "abbc"' a c
    Which is why you should always use // (or m:: or whatever). Without that habit, it's easier to say things like split "." (which devours all input except newlines :) or split "?" (which dies, since that's not a valid regex) by accident.

    Though, as I said, split ' ' is an exception.

Re: Re: A question on splitting
by duff (Parson) on Jan 14, 2004 at 21:10 UTC
    I think that using quotes suppresses regular expression processing in split, though

    Nope. The first argument to split is always a regular expression except for the one special case of " "