in reply to merging .csv text input based on matching column field values in multiple rows
I do realize looping and other logic are not allowed inside here docs so i'll need to rethink thatFor your next implementation, perhaps think of using a full blown templating solution, such as Template::Toolkit which allows the logic to reside (partially) inside the template.
I had a similar problem and solved it by having the Perl script extract the data from the data sources, out it in a standard format (data structure) and then have Template::Toolkit-templates turn it into the required output-formats. Now, every time I need to have a new output format, I just have to write a new template and do not have to write a new script.
Alternatively, have a look at XML::Code which allows easy writing of XML-code or XML::Generator which is a bit more involved but has more possibilities. Both modules will take care of escaping "forbidden" characters.
Update: How could I forget XML::Writer? This venerable module has everything, but is not easy to use and I find it overkill for some more simple tasks. However YMMV.
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
|
|---|