You keep on using that word 'split' ... i do not think
you know what it means. ;) Consider the following:
my $str = 'foo,bar,moo,cow';
my @value = $str =~ m/(\w+)\,?/g;
print "@value\n";
@value = split(',',$str);
print "@value\n"
They both achieve the same results, and guess which one is
easier to understand?
You say have non-repeatable fields, how does using a regex
make this easier than split? What do you think split uses
to split? A regex! Besides, oro has a family of
split
functions. You could always do a series of splits if
multiple delimiters are used:
my $str = 'a,b,c:d,e,f:g,h,i';
my @part = split(':',$str);
foreach my $part (@part) {
my @subpart = split(',',$part);
print "@subpart\n";
}
The split functions found in the org.apache.oro package
can do this, you just have to jump through more hoops. ;)
Not that it matters, but one of my beefs about Java is not
being able to process lists easily like you can in Perl:
print $_,$/ for map split(',',$_), split(':', $str);
Best of luck.
jeffa
L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)
|