Your second split is attempting to use ~ as the match character, not |. Did you intend to use $sep? Actually, even that won't do what you want because you need to quote | (it is a regex meta character). Something like:
@arr = split /\Q$sep\E/, $var;
In reply to Re: problem in splitting on special character
by GrandFather
in thread problem in splitting on special character
by denzil_cactus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |