Known as much for its confusing, often oddball, syntax as for itsefficiency and speed, Perl has a mystique that very few languages canmatch. This first article in a new series gives novice and intermediateprogrammers an introduction to the basics of the language.
If you're a Web programmer, you're probably already well-versed with the intricacies of client-side scripting. But where there's a client, there must be a server - and so, this week, DevShed is kicking off a series of tutorials on server-side scripting. With power such as this, young Jedi, there is no limit to the evil you will be capable of...
First, though, let's start with the basics.
Server-side scripting is not new. It's been around for quite a while on the Web, and almost every major Web site uses some amount of server-side scripting. Amazon.com uses it to find the book you're looking for, Yahoo! uses it to store your personal preferences, and GeoCities uses it to generate page statistics.
Despite this, you're probably wondering why server-side scripting is such a big deal - after all, you've probably seen what a few simple JavaScripts can do. The reason for its popularity is very simple - JavaScript runs within a client application, usually the browser, and as such can only access resources, such as the current date and time, on the client machine. Since server-side scripts run on the Web server, they can be used to access server resources such as databases, system variables and other useful thingamajigs.
Just as there are different flavours of client-side scripting, there are different languages which can be used on the server as well. Here's a quick list of some of the more popular ones:
Active Server Pages [http://msdn.microsoft.com/workshop/server/asp/ASPover.asp] was introduced by Microsoft in its IIS Web server, ostensibly for the purpose of "web application programming". While ASP currently runs only on the Windows server platform, plans are afoot to port it to the UNIX platform as well.
Next up, ColdFusion, developed by Allaire [http://www.allaire.com]. ColdFusion syntax bears a remarkable resemblance to HTML, making it very easy for a budding web programmer to migrate to it. At the moment, it's available for both Windows NT and Linux. The only drawback: it ain't free, McGee!
Python [http://www.python.org] is an interpreted, object-oriented high-level scripting language for UNIX, often compared to Tcl, Perl or Java. It has modules, classes and interfaces to system calls, and is also extensible. It has been ported to Windows, DOS, OS/2 and the Macintosh, and has a devout following in the UNIX community.
And then there's the current flavour of the month, PHP [http://www.php.net]. Very easy to use, it's free, widely available for UNIX systems, and particularly strong in the areas of database access. The latest version is PHP4, and a final release is expected shortly.
And finally, Perl, one of the most popular languages around [and the language used throughout this tutorial - such is fame!]. Here's how its creator, Larry Wall, describes it: "PERL, an acronym for Practical Extraction and Report Language, is an interpreted language optimized for scanning arbitrary text files, extracting information from these files, and printing reports based on that information. It is also a good language for many system management tasks. The language is intended to be practical - easy to use, efficient, and complete - rather than beautiful - tiny, elegant, and minimal.