in reply to split() problem

split uses a regular expression and not a plain string for splitting (mostly). Your string * gets interpreted as the regular expression /*/, which is nonsensical. You could have shown us how it "fails" for you. I think you want to use split /\*/ instead, which will split on literal asterisks in your data.

Replies are listed 'Best First'.
Re^2: split() problem
by Anonymous Monk on Jan 24, 2007 at 09:00 UTC
    "split uses a regular expression and not a plain string."

    Thanks for that answer.
    /\*/ works, "\*" fails because of delimiters in regex.
    Bad day for me, many thanks for your help :)

      "\*" fails, because "" interpolates \*, which results in a bare *.

      Watch following:

      $ perl -wle 'print "\*"' *

      So you actually should, if (see Corion's reply), use '\*'.

      "\\*" would work.

      The string literal "\\*" results in the string \*.
      When used as a regexp, the string \* matches *.

      Save yourself a lot of headaches and always use /.../ (or m{...}) with split.