Article
Programming Perl 101
1.) Background Information
If you run a website, you've probably heard of either Perl or CGI at some point. Whether you've merely heard of it, installed a few scripts on your own, or taken one look at the code and turned pale, this tutorial is for you.
Perl is a programming language. Many people think CGI is a language, as in, "I'm going to learn CGI," but this is erroneous. Think of CGI as the method in which you use Perl. You can write CGI scripts using other programming languages, but Perl is far the most common due to its relative simplicity and power.
Even as more efficient programming languages are starting to take away Perl's popularity, Perl programming remains very popular and learning it is not a waste of time. For example, PHP is similar to Perl in most respects. The syntax used is similar and a lot of the basics are somewhat the same. If you know Perl, you've got a huge head start at learning PHP, and a few other languages as well.
Although Perl may be less efficient than other programming languages like PHP or ASP, there are still infinitely more freeware and shareware scripts out there written in Perl than in any other language. In other words, Perl isn't going away anytime soon.
2.) A Few Small Rules
Now that you have a little background on Perl, let's get down to some of the basic commands.
Like any programming language, Perl has rules. You will need to use certain symbols in certain places to tell the script something. One of the most basic rules in Perl is that every line must end with a semi-colon: ";" . As with every rule there are a few exceptions which we'll go into later, but for now just realize that almost every line of Perl code that you write will end with a semi-colon. The semi-colon, in case you're wondering, tells Perl that it has reached the end of a command.
Chris is a regular on the SitePoint Forums and goes by the username "TWTCommish". He also runs the