http://qs1969.pair.com?node_id=238225


in reply to Re: best way to change xml record using XML::Simple?
in thread best way to change xml record using XML::Simple?

While I agree with some of your thoughts, I personally try to avoid CSV files because the definition of "CSV" is so elastic in practice. How do you quote or escape field containing commas and quotes? How do you handle trailing empty fields? I've seen a lot of variation in stuff that is ostensibly "CSV", and that always makes me nervous from a long-term maintainability and interoperability standpoint.

That said, I do agree delimited files can make a lot of sense for lightweight data storage. For information that normally wouldn't contain internal whitespace other than "regular" (ASCII 32) spaces -- and this application might qualify -- I often choose tab-delimited.

One potential benefit I do see to using XML in this application is that you can easily store data that isn't quite so regular. For example, if you wanted to support multiple contact phone numbers, it would be fairly easy to expand the data structure like this:

<record> <!--existing stuff--> <contact_phone_number note="business">123-4567</contact_phone_number> <contact_phone_number note="pager">555-6789</contact_phone_number> <contact_phone_number note="vacation home in Bermuda">+1-99-20-55-6789 +</contact_phone_number> </record>

Dealing with irregularities like that would be a bit more work in a rigid db-like or non-hierarchical file format.

        $perlmonks{seattlejohn} = 'John Clyman';