in reply to split problem when emptiness is a valid element
givesuse Data::Dumper; my @array = split /\|/, 'A|B||', -1; print Dumper(\@array);
from the docs for split:$VAR1 = [ 'A', 'B', '', '' ];
split /PATTERN/,EXPR,LIMIT...
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.
- Comment on Re: split problem when emptiness is a valid element
- Select or Download Code