What Is Perl?


Perl is a high-level, powerful programming language originally developed by Larry Wall. It is an ideal language for quick prototyping of applications and production systems. Perl has file- and text- related functions that make it the ideal language for manipulating text files. In addition, Perl also supports graphical programming, applications requiring database access, network programming (that is, sockets), and web-based programming. As you can see, Perl has support for just about every possible component of an application.

Perl also has several strengths that make it the perfect language for processing XML documents, as you'll see in the following sections.

Text Manipulation and Processing

One of Perl's major strengths is the suite of built-in tools and functions for text manipulation and processing. Because Perl was designed for data processing, you can do just about anything you want to data with a small Perl script. For example, it's very easy to search, replace, or match any pattern in a string or document using the built-in regular expression engine. A regular expression is used by Perl to search for patterns in a text string or file. Because XML data is plain text, it would seem natural to use Perl to process (that is, build, parse, or search) XML data. When Perl operates on XML data, it is just doing what its strength is ”manipulating text.

Extending Perl's Core Functionality Through Modules

Perl's core functionality can be easily extended by the use of modules. A module is a self-contained block of Perl code that performs a specific task. It is similar to a library in that it provides an application with additional functionality.

One of the more powerful modules available for Perl is the Database Interface (DBI) module. The Perl DBI module provides you with an API to a large number of supported databases. This module provides you with a standard API, which is independent of any underlying database dependent issues. The end result is a very powerful tool that can be the basis for a number of applications.

Another perfect example of a module is XML::Parser, which I'll be using for several examples throughout the book. XML::Parser provides an API to an XML parser library (written in C by James Clark) called Expat . Most of the low level parsing work is hidden from the user , and as a result, you interact with the parser through a clean, thought out, and well-defined interface, which makes the task of parsing an XML document much simpler.

Literally hundreds of Perl modules (more than 450 at the time of this writing) have been developed to support XML processing. This means you will find support for just about every XML-related task (such as writing, parsing, searching, and publishing). If not, then chances are someone is working on a module that does exactly what you need. And if not, you can always develop your own modules to support application or project-specific requirements.

As you make your way through this book, you'll see the power of modules, especially when they are utilized in an application. For example, the ability to query multiple database servers, combined with the ability to generate XML files, enables you to generate XML documents from any of the supported database servers. Modules also provide the reverse capability; by combining the XML::Parser module and the DBI module, you can parse XML documents and store their contents in a database.You'll be able to perform a lot of complicated tasks when you take advantage of the power of Perl modules.

Perl Portability

One of the greatest benefits of using Perl is the fact that it is available for just about every operating system in use today. It is usually included as part of the standard distribution with Unix operating systems; but if not, both source code and binary downloads are readily available. Binary distributions of Perl are available for more than 50 platforms, see http://www.perl.com/CPAN/ports/index.html for the list.

You can visit a number of web sites to download a binary distribution of Perl if it wasn't included with your operating system.You can download either source code or binary distributions at http://www.cpan.org, http://www.perl.com, or from any number of mirror sites. Usually, if you're running a Unix-based system, it's best to download the source code and recompile Perl ”this assures you that you are getting the latest (and greatest) version. If you are using a Microsoft Windows-based system, then I recommend using the Perl distribution from ActiveState (http://www. activestate .com).

Web Programming

As dynamic web content came into mainstream web programming, Perl has quickly and surely taken over the market of Common Gateway Interface (CGI) programming, designed to interface between the server side and the client side of the web. Although many technologies now exist (such as Java Servlets, Java Server Pages (JSPs), Active Server Pages (ASPs), Personal Home Pages (PHPs), and so on), Perl continues to dominate the web server-side programming market due to its data processing facilities and ease of use. Because the web is all about processing and displaying data, Perl just naturally fills that position. Even though other technologies (such as Java Servlets) have some benefits over CGI, there are several strong reasons to use Perl. Mod_perl was developed as an answer to the newer technologies, such as JSP, ASP, Java Servlets, and PHP. Mod_perl is an Apache web server plugin module, which provides a built-in Perl interpreter. By using the mod_perl interpreter, scripts can benefit from the power of directly accessing the server API while running much faster and more efficiently . A few Perl technologies also exist to enable the embedding of Perl into HTML to complement technologies like ASP, JSP, and PHP.

Open Distribution

Perl is available at no cost to users. The original developer of Perl, Larry Wall, believed in an open distribution policy. As a result, Perl is developed and supported by a worldwide network of volunteers. They are (as they say on the Perl web page) "committed to producing better software for free than you could hope to purchase for money." Perl is distributed as part of the GNU software project, but Perl usually falls under a more open license.

Excellent Support from the Perl Community

Perl is developed and maintained by a community of open-source developers. The Comprehensive Perl Archive Network (CPAN) at http://www.cpan.org houses thousands of Perl modules and scripts, developed by many authors, that deal with just about any task at hand. If you need a Perl module to perform a particular task, chances are it already exists on CPAN.

Quite a few companies offer Perl distributions along with support. Some have even developed Perl development environments that they either sell or freely distribute. A variety of tools are available. For example, look at http://www.perl.com; this is the main source for Perl information, including an extensive list of Frequently Asked Questions (FAQs) and Perl-related articles and tutorials.

What makes Perl stronger than any other language is the community of dedicated developers and available support. CPAN, as I mentioned, is the central point to look when you are trying to solve a problem and require a module to help you do it.

Numerous mailing lists, newsgroups, and websites related to Perl exist. Some of the most popular ones include

Newsgroups

comp.lang.perl.announce

comp.lang.perl.misc

comp.lang.perl.modules

comp.lang.perl.tk

Mailing lists can be found by going to the following link, which lists most of the Perl-related mailing lists:

http://www.perl.com/cs/user/query/q/6?id_topic=50



XML and Perl
XML and Perl
ISBN: 0735712891
EAN: 2147483647
Year: 2002
Pages: 145

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net