Learn about Perl

What is Perl? It is one of the oldest web programming language around. Practically every Linux based server comes with support for it by default. Perl is a server-side, scripting language that can output dynamic web pages or web applications. Perl code, like PHP, is run on the server and then gives HTML back to the web browser.

Perl's Capabilities

Because Perl has been around since 1987, it is available on nearly every platform, Windows or Linux. Perl was originally developed for text manipulation but can now be used for managing email, connecting to other web sites or servers, processing form information, storing information in a database, reading and writing to text files, creating cookies in a web browser, and much more. Perl also support subroutines (blocks of code that can do specific things over and over).

Learn About Perl

Learn about Perl's syntax

Perl borrows a lot of syntax from the C programming language. Syntax is the wording and way that the language has to be used for it to work. Perl is designed to be practical so it can be easy to understand but it can also be complex so a higher-level language such as PHP would be a better choice for you if you are a beginning programmer. Perl uses typed variables that store a particular type of data (text, numbers, arrays, scalar, etc.). Here are some important things to learn about Perl:

  • Filename. You can name your Perl files anything you like.
  • Variables. Most variables are marked by a leading character which identifies the type of variable:
    • $foo # a scalar
    • @foo # an array
    • %foo # a hash
    • FOO # a file handle or constant
    • &foo # a subroutine. (The & is optional)
  • Comments. You can comment out code using the hash character (#).

You can code Perl in any text editor but it may help to use one that has syntax highlighting or other features. What does Perl code look like? Here is a sample:

$yesterday = parsedate('yesterday');
$printdate = strftime('%a, %b %d', localtime($yesterday));

open (FILE, ">$dir/index.html");
for (@index) {
if (/INSERT HERE/) {
print FILE "$_";
print FILE "<td><a href=\"host-shopper.$id.gif\">$printdate</a></td>\n";
if (($id % 5) == 0) {print FILE "</tr><tr>\n"}
}
else {print FILE "$_"};
} # End for
close FILE;

We recommend that you learn about Perl from its site at Perl.org. Sitepoint also offers some great CGI & Perl Tutorials and PerlMonks has a great introduction to Perl if you want to learn more about Perl. We also recommend using a book from the library or one of the following:

If you are looking for some web hosting to use Perl on, check out our our Hosting Wizard to find web hosting that best meets your needs.

© Host Shopper | Web Host Comparisons | All Rights Reserved