|No such thing as a small change|
best way to change xml record using XML::Simple?by waxmop (Beadle)
|on Feb 24, 2003 at 18:31 UTC||Need Help??|
waxmop has asked for the
wisdom of the Perl Monks concerning the following question:
Greetings wise ones:
I just wrote a clunky application, and I want to get the community's feedback, because I don't like how I wrote it.
Background: the people I work for need a way to search, add, and edit their records of contacts at a bunch of different companies. For example, when somebody gets a new phone number, we need to be able to update our records.
Here's the overview of what I did:
The xml file looks sort of like this:
I wrote some perl-mason pages to allow users to search records after parsing the data with XML::Simple. They can edit a record by filling out a form on the post_edits.html page. Here's what happens on the post_edits.html page:
I pass the new edited record in the %ARGS hash. Then I create the $newnode structure which will replace the old record. Then I loop through my in-memory structure until I find the record that I want to replace, and then I replace it, with the $rec = $newnode line. I've used Data::Dumper to check that it works, and it looks good, but I can't help but wonder if there is a better way.
All comments and criticism are welcome. Let the didactic abuse flow!
update (broquaint): added missing </ul>