in reply to Re: split trying to look for /
in thread split trying to look for /

You could escape the back-slash, or more readably, pass it in using an alternate delimiter, or simpler still, as a string

Actually, that's not a string; it's a regular expression with single quote delimiters. The first argument to split() is always a regular expression except in the one special case of ' '. Try splitting on '*' sometime. :-)

Replies are listed 'Best First'.
Re^3: split trying to look for /
by Coruscate (Sexton) on Dec 16, 2003 at 18:14 UTC
    The first argument to split() is always a regular expression

    Has this always been true? I remember a time long ago when I tried to use split "\n", "foo\nbar"; and got an error stating that using double quotes to split on a newline was wrong and that split /\n/, "foo\nbar"; should be used. I just tried a one-liner with warnings and strict enabled and did not get that same warning/error. Would you know why using double quotes used to give funny results?

      I have never seen nor heard of such behavior before, so I can't answer that. However, as to whether it's always been true that the first arg to split() is always a regular expression ... it's been true at least since perl 4 :-)