in reply to Re: Wierd funky problems with split
in thread Wierd funky problems with split

Your answer is not quite right. test with this:
$a = "12||23||34||45"; @a = split("\|\|", $a); print join(",", @a);
Instead of giving you,
12,23,34,45
It gives you
1,2,|,|,2,3,|,|,3,4,|,|,4,5
You have to say:
$a = "12||23||34||45"; @a = split(/\|\|/, $a); print join(",", @a);
Or, if you want to use quots, say:
$a = "12||23||34||45"; @a = split("\\|\\|", $a); print join(",", @a);
The reason is simple:
  1. For that "|", you need to escape it within regexp, but not within quots.
  2. For that "\", you have to escape it within quots.
So if you say "\\|",
  1. First it is being intepreted by the quots as "\|",
  2. Then it is being further interpreted by the regexp as "|".