in reply to split but not consumed

davido answered this excellently, so I'd like to whine about a pet peeve: using a quoted string as the first arg to split. I would write that as split(/foo/,split(/w00tx0r/,"bla foo w00tx0r moo"));.

Using "foo" instead of foo seems to create the false impression that split will work with either a regular expression or an exact string. Then you see things like split ".", which should really be split /\./.

Split only takes a regex (with the confusing exception of " "), so show it that way.

Replies are listed 'Best First'.
Re^2: split but not consumed
by davido (Cardinal) on Jul 23, 2004 at 07:23 UTC

    I laughed out loud when Abigail-II posted this response to a question of why $string =~ "stuff" works.

    Of course, with regards to split, a single quoted, single space, is a "special case."


    Dave