in reply to split problem when emptiness is a valid element
perldoc -f split
...
If LIMIT is specified and positive, it represents the maximum number of fields the EXPR will be split into, though the actual number of fields returned depends on the number of times PATTERN matches within EXPR. If LIMIT is unspecified or zero, trailing null fields are stripped (which potential users of "pop" would do well to remember). If LIMIT is negative, it is treated as if an arbitrarily large LIMIT had been specified. Note that splitting an EXPR that evaluates to the empty string always returns the empty list, regardless of the LIMIT specified.
It's a little confusing but I think these two examples will make it clear:
$string = "a|b|||"; print "'" . join ("', '", split(/\|/, $string)) . "'\n"; print "'" . join ("', '", split(/\|/, $string, -1)) . "'\n";
Update: I'm too slow, inman submitten his node sooner than me ;-)
Jenda
| XML sucks. Badly. SOAP on the other hand is the most powerfull vacuum pump ever invented. |
|
|---|