use Perl Log In
My current project loomed over my cube like a foreboding fortress. My usually focused mind was easily distracted as I thrashed about, trying to come up with a "magical solution" to the overwhelming problem before me.
The problem: I work for a large organization (perhaps part of the problem
When I embarked on this quest for the "magical solution," I was advised to look into XML. Immediately, I was comforted by the security of knowing that other Perl hackers had walked this path before. I knew that if I could learn enough XML to get started, a visit to CPAN would surely provide me with the resources I needed.
Once I had a few XML documents under my belt, I headed off to CPAN to pick up some tools. XML::Parser was the first module I came across. Due to my laziness, though, I quickly became disheartened at the number of styles, handlers, and constructor arguments I had to deal with.
I continued down the aisle until I found XML::Simple. This was more like it! A few lines of code produced an XML document packed into a neatly organized Perl object, ready for manipulation! Ahh, laziness has its rewards. My triumph was short-lived. As I started doing some preliminary tests with XML::Simple, I learned about DTD's and "valid" XML documents. I wondered if XML::Simple validated the XML it so nicely parsed. The module lived up to its name and did not.
With a slightly more educated eye, another perusal of CPAN produced the "magical solution" I was looking for (and ironically brought me back to where I had started). XML::Checker::Parser extends XML::Parser, and this time, it didn't scare me quite so much. I held my laziness in check long enough to do some preliminary testing with the less "Simple" interface and was handsomely rewarded with the ability to create a "valid" XML Perl object in just 3 lines:
Now, when I look upon the fortress that is this project, it does not feel as intimidating as it once was. My coding skills alone would be futile against such a task, but utilizing this module has given me access to the powerful skills of its authors: Enno Derksen (XML::Checker), Clark Cooper (XML::Parser v2.x), and Larry Wall (XML::Parser v1.0). Perl's power isn't found in any one individual's abilities, it is found in the collective strength of the multitude of CPAN authors.use XML::Checker::Parser;
my $cp = new XML::Checker::Parser(Style => 'Objects');
my $obj = $cp->parsefile($xml_doc);