my @fields = split(/\+/, $string);
Regards,
svenXY | [reply] [d/l] |
refer split documentation for more information. | [reply] |
As an elaboration on svenXY's answer: Presumably your problem is that you tried split /+/, $string and got the complaint Quantifier follows nothing in regex …. That's because + has special meaning to the regex engine ("one or more of the preceding …"), so you need to escape it with a backslash to remove its special meaning. That gives split /\+/, $string, as indicated. See Regular Expressions for more details on special characters (and a lot of other things). | [reply] [d/l] [select] |
To further elaborate ... the first parameter to split() is always a regular expression (except the split ' ',... special case). Even if you enclose the parameter in quotes. So even split '+', $string emits that error message. IMHO, it's bad design, but that's the way it is. If you do want to split on a literal string and not have to worry about special characters you have to use split /\Q$separator\E/, $string.
| [reply] [d/l] [select] |