in reply to RE: Re: Where oh where should I initialize my vars?
in thread Where oh where should I initialize my vars?

Ok, point taken, but in my (perhaps pathetically weak) defense, if that is the official behavior, then it ought to be documented in perlfunc, not just in a book (even if it is The Camel book :-).
  • Comment on RE: RE: Re: Where oh where should I initialize my vars?

Replies are listed 'Best First'.
split $str (Re: Where oh where should I initialize my vars?)
by tye (Sage) on Oct 26, 2000 at 21:00 UTC

    I'd vote for using /\t/ as it is much more self-documenting. Seeing split "\t" makes me wonder what split '\t' does. Well, all of these are the same (they split on tab):

    split /\t/ split "\t" split '\t' split "\\t" split '\\t' split "\\\t"
    while all of these are the same (they split on backslash followed by "t"):
    split /\\t/ split "\\\\t" split '\\\\t' split '\\\t'

    Did that surprise you? I can certainly seeing that surprising a non-perfect Perl coder who takes over maintanence of your code.

    I think split $string would be more DWIM if it translated into split /\Q$string\E/, which it doesn't. So I think you should avoid using it as it makes your code harder to maintain. (Except for the special case of split " ", of course.)

            - tye (but my friends call me "Tye")