Keep It Simple, Stupid | |
PerlMonks |
removing the spaces from keys of a complex hashby gwhite (Friar) |
on May 07, 2008 at 16:15 UTC ( [id://685250]=perlquestion: print w/replies, xml ) | Need Help?? |
gwhite has asked for the wisdom of the Perl Monks concerning the following question: I have an older legacy module that returns me a hash with a couple of hundred keys. This module is in use by several other parts of the application so rewriting it is not desirable. The hash that is returned to me has some of the values as hash references. My desire is to write the hash out as XML using XML::Simple. Part of the trouble is that some of the keys have spaces in them which means the XML is not well formed. Keys in the hash references also suffer this affliction. What I cannot get my mind around is how to parse through the hash and hash references, then use a regex to strip the spaces from the keys, and result in a hash with XML valid keys.
Once I have printed the XML file, I am done with the data so changing the keys at this point will not impact any other processes. Here is what I have come up with at this point (but it does not seem to be affecting the hash references)
Any insight would be appreciated
g_White
Back to
Seekers of Perl Wisdom
|
|