in reply to Re: newbie regex question: substituting repeating occurences for different replacements
in thread newbie regex question: substituting repeating occurences for different replacements
I posted a few solutions to converting CSV to XML over at CSV to XML (the quick and dirty way). Ultimately, CSV::XML looks the easiest, but i still dig using XML::Generator::DBI. One option i didn't try at the time, however, was DBD::AnyData. Here's one that follows the <colN> naming convention and uses the previous two modules ... but, caveats:
use strict; use warnings; use DBI; use XML::Generator::DBI; use XML::Handler::YAWriter; my $max = 5; my $data = join(',',map"col$_",1..$max) . do {local $/;<DATA>}; my $dbh = DBI->connect('dbi:AnyData(RaiseError=>1):'); $dbh->func('test', 'CSV', [$data], 'ad_import'); my $generator = XML::Generator::DBI->new( Handler => XML::Handler::YAWriter->new(AsFile => '-'), dbh => $dbh, Indent => 1, ); $generator->execute('select * from test'); __DATA__ colContents,nextColContents,lastColContents colContents2,nextColContents2,lastColContents2 colContents3,nextColContents3,lastColContents3 a,b,c,d,e f,g,h,i j,k l m,n,o
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)
|
|---|