Ed Avis wrote: > Shawn H. Corey <shawnhcorey <at> gmail.com> writes: >> Why on earth would you want to invert an XML file? > > What I mean is that many modules (such as XML::Twig) return data as hashes. > To me, it doesn't make any sense to return both a hash and its inverse from > the function. Instead I would return just one hash. But why? An XML file contains two parts: mark-up and content. To have the mark-up as the key and the content as the value makes sense. For example, if you want to find the publication date, you look for the key 'publication_date'. To invert such a hash would mean you want to find the markup for the content. For example, you could ask, what is the markup for 'Aug. 4'? Sure, you can get the information but what are you going to use it for? The only possible reason for doing this is that someone tried to be clever and stuffed some content into the markup, which now has to be extracted (and you already know my opinion on clever :). To me, inverting a hash is just another round of Perl Golf, not something I would use in Real Code. ;) -- Just my 0.00000002 million dollars worth, Shawn Programming is as much about organization and communication as it is about coding. My favourite four-letter word is "Done!"Thread Previous | Thread Next