XML technologies / XML / Perl & XML / Perl and XML / Why use Perl and XML?
(Excerpt from “Perl & XML” by Erik T. Ray & Jason McIntosh)
First, Perl excels at text through filehandles, here-documents, string operations and built-in regular expressions. Anyone who has done string work in C and then Perl knows which suits it better. XML is still text at heart, making Perl ideal for it.
Since version 5.6, Perl has progressively supported encodings based on Unicode, especially UTF-8. These character sets matter especially in XML. We discuss character sets further in “XML basics: reading and writing.”
Second is CPAN, the Comprehensive Perl Archive Network, an inexhaustible source of freely usable modules, mirrored around the world. Self-reliance is admirable, but check this free store of ready solutions before reinventing the wheel: it saves time and effort. Why write your own XML parser when tested, configurable ones exist? CPAN is more bargain bin than furnished showroom: many people contribute with almost no oversight. There are gems, and new technology quickly brings new software, especially useful for XML with its ever-growing standards.
Early XML modules proliferated with their own APIs and styles: innovative and useful, but not interchangeable. Now common interfaces make replacement easier. If one SAX parser disappoints, choose another. Despite little central control, CPAN cooperates and steers its own currents.
Third, Perl’s flexible object orientation suits XML. A document grows hierarchically from one root, with nested children. Its elements naturally become objects of one class and API. Markup encapsulating content resembles objects encapsulating code and data. XML processors modularize well into parser objects, factories creating them and result objects, yielding clear, portable code.
Fourth, remember Perl’s web connection. Java and JavaScript take the glory, but Perl quietly works somewhere on most servers.
Note: Much as most companies have an old box secretly running Linux rather than Windows—just do not tell management. Translator’s note.
Many dynamic-web libraries adapt easily to XML. Their developers, having built them over years, eagerly await applying that knowledge to XML.
Ultimately choose the language fitting your needs. Perl is ideal for XML; do not just take our word, try it yourself.
Copyright © 2003 O'Reilly Verlag GmbH & Co. KG
You may print the online version for your private use.
Otherwise, this chapter from “Perl & XML” is subject to the same conditions as the bound edition: the work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
O’Reilly Verlag GmbH & Co. KG, Balthasarstraße 81, 50670 Köln, kommentar(at)oreilly.de
back to top