It's helpful to remember that the first parameter to split will always be treated as a regular expression (with the one exception of " "). Variables work fine in regular expressions and are expanded before the expression is evaluated, so your code boils down to @list = split "|", $line;. Since the pipe symbol (|) is special in regular expressions, you need to escape it. This is typically done with quotemeta
In reply to Re: split question
by duff
in thread split question
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |