These classnotes are depreciated. As of 2005, I no longer teach the classes. Notes will remain online for legacy purposes

UNIX01/Introduction To Perl

Classnotes | UNIX01 | RecentChanges | Preferences

What is Perl?

From the Perl documentation:

Perl is a high-level programming language with an eclectic heritage written by Larry Wall and a cast of thousands. It derives from the ubiquitous C programming language and to a lesser extent from sed, awk, the Unix shell, and at least a dozen other tools and languages. Perl's process, file, and text manipulation facilities make it particularly well-suited for tasks involving quick prototyping, system utilities, software tools, system management tasks, database access, graphical programming, networking, and world wide web programming. These strengths make it especially popular with system administrators and CGI script authors, but mathematicians, geneticists, journalists, and even managers also use Perl. Maybe you should, too.

See also http://www.sysadminmag.com/tpj/whatisperl.html

Perl has many strengths in that with it you can get a project or script up and running very quickly. However, it also has some weaknesses that make maintaining large-ish Perl scripts more difficult than needs be.

Confessions of a Perl Lover

Alright, I need to confess something: I love Perl. Perl is perhaps my favorite language to code in. Perl's syntax is so easy and laid-back that it can be a regular joy to work with.

One of Perl's strengths is that it is a loosely typed language (meaning that a variable can be any type, and that type is inferred by the compiler). It is also a loosely structured language, which means you can get away with a wide variety of coding styles and syntaxes. Basically, before Perl chokes on a command or variable, it first tries to figure out what you meant by its usage.

This is a strength because it means picking up Perl and writing a new script with Perl is very easy. Even if your syntax isn't perfect or if you have certain minor "mistakes", Perl will probably just chug along fine and your script will work as expected.

However, this leads to one of Perl's weaknesses. Because it is so laid-back and loose, it allows you to be lazy when developing with it. This means that errors can creep into your code without you noticing, and those errors can propagate through your future code because that's the way it worked previously. Eventually that error will come back to bite you, and you will be ill-equipped to see the error because it's "always worked before!"

This can also mean taking a look at someone else's Perl code, or even looking at your own from months to years back, can be very confusing. They may be using style and syntax so alien to what you've seen before that it doesn't even look like Perl to you.

In most computer languages there could be hundreds of ways to solve a particular problem. In Perl, there is likely thousands considering it's loose structure- and each way could look dramatically different.

This point being made, I still love Perl. It's elcectic and funky, but can be a very powerful tool in any system administrator's arsenal (even a Windows administrator ;-)

Perl can be both a procedural and an object-oriented language. Some people argue that the object-oriented aspect is "cobbled on" (like C++ was with C), but others argue that it only appears "cobbled on" because Perl is such a loose language.

Misc. Perl Links:



Classnotes | UNIX01 | RecentChanges | Preferences
This page is read-only | View other revisions
Last edited July 26, 2003 1:46 am (diff)
Search:
(C) Copyright 2003 Samuel Hart
Creative Commons License
This work is licensed under a Creative Commons License.