![]() |
Perl
|
|
|
Perl, the Pathologically Ecclectic Rubbish Lister. The acronym has 2 definitions (at least), that given above, and its more commonplace one: Practical Extraction and Report Language Perl is an absolutely amazing scripting language that is available on all the popular operating systems today. Amongst other things it has text search and replace, Web CGI, built-in access to many good C and Unix functions (even on non-Unix platforms), modular access to practically all RDBMS in common use and much more besides these. A lot of people have heard about Perl and think that it is only used for Web programming to produce Common Gateway Interface (CGI) scripts. Although this is an excellent example of where Perl is used (and probably the most common) it is certainly not the only thing that Perl is good for. The language is great for quickly creating a solution for simple problems, but is also excellent for the more complex problem where a robust solution is required. With the use of an object oriented approach, code can be well structured, maintainable and extensible. The creation of complex systems with many OO modules in just a few weeks is easily achievable. I would recommend a couple of books to help you get started. They are both published by O'Reilly & Associates, Inc and are Learning Perl and Programming Perl. You can find some progressively more complicated perl scripts on the downloads page. Perl ModulesPerl can be split into modules containing procedures and functions, or if required, fully fledged objects. For more on this see the Perl Modules page. Perl and the WebWith standard distributions of Perl, a module called CGI.pm is provided especially to make handling input and output from CGI scripts easy. It provides many functions including some to handle the more cumbersome mechanisms like cookies, escaped URL strings and multiply selected <SELECT> form elements. In the Web environment, Perl is most commonly used in CGI scripts that must return output that is dependant upon their input, IE pages with dynamically assigned content. There are many ways of doing this but I like the template approach. This is where the HTML is kept in a file separate from the script and is read and output according to the needs of the script. This allows the HTML file to be pretty much standard, but it is split internally in blocks so that the script can output them as required. The blocks also have placeholders within them so that if necessary content can be output in their place. Check out the downloads page for a couple of modules that allow you to do just that. Perl Website MaintenanceMaintaining a web site with an ISP that does not support server side inclusion can be a tiresome chore. Take a look at this helper script that makes use of template web pages and pre-upload client side includes. Perl in an RDBMS environmentYou can probably get access to your RDBMS through Perl too. The best supported mechanism for this is to use the DataBase Driver (DBD) and DataBase Interface (DBI) packages. DBI is the common access layer through which the script connects to the database engine specific wrapper layer, DBD, which in turn communicates to the underlying DB. There are a number of different databases that Perl can provide access to through these packages. The supported list of databases grows continually. I have used MySQL, Oracle and PostgreSQL in this manner with little change to scripts to when changing from one to another. What happens with DBD and DBI is that you essentially get an object interface to the database with a bunch of member functions that you can use to execute SQL. As the interface is via an object you can even log in several times to the same DB under different users, as each session gets its own handle to the DB. RDBMS and CGICoupling the RDBMS functionality to a Web server via the CGI mechanism is a quick and easy way to provide on the fly DB enquiries and even to do data entry. Simply create an HTML form with the required fields in it and send that to the Perl script on the server. |
|
Content of this page Copyright © Robert Quince 1996 - 2005. |