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") |