Perl Intro
Perl is a general-purpose programming language created by Larry Wall in 1987. Wall was a system administrator who needed something more powerful than shell scripts and awk for producing reports from text files, but quicker to write than C. The result borrowed ideas from all of them and grew into one of the most influential scripting languages ever written.
The name is officially not an acronym, though two backronyms are popular: "Practical Extraction and Report Language" and, affectionately, "Pathologically Eclectic Rubbish Lister".
use strict;
use warnings;
print "Hello from Perl!\n";
my $language = "Perl";
my $born = 1987;
my $age = 2025 - $born;
print "$language has been around for $age years.\n";Hello from Perl!
Perl has been around for 38 years.
Even this tiny program shows three Perl trademarks: variables start with a sigil ($ for a single value), strings in double quotes interpolate variables, and every statement ends with a semicolon.
A short history
| Year | Milestone |
|---|---|
| 1987 | Perl 1.0 released on Usenet |
| 1994 | Perl 5: references, modules, objects, my variables — the language you will learn here |
| 1995 | CPAN, the Comprehensive Perl Archive Network, opens |
| 2000s | Perl powers much of the early web as "the duct tape of the Internet" (CGI scripts) |
| 2019 | Perl 6 is renamed Raku and becomes a separate language |
| 2020s | Perl 5 keeps evolving: signatures (5.36), the class feature (5.38), try/catch (5.40) |
Note: "Perl" today means Perl 5. Version numbers continue as 5.x (this course runs Perl 5.42). Raku is a different language with a different syntax.
Where Perl is used
- Text processing: log analysis, report generation, data cleaning, format conversion. Perl's regular expressions became so popular that most other languages copied them ("Perl-compatible regular expressions", PCRE).
- System administration: Perl is installed on nearly every Linux and macOS machine, so admins use it for glue scripts and one-liners.
- Bioinformatics: BioPerl was a pioneer for processing DNA and protein sequences.
- Web and legacy systems: large codebases at banks, airlines and sites such as Booking.com and DuckDuckGo were built in Perl.
- Build and test tooling: parts of Git, the Linux kernel build and many test suites use Perl.
The Perl philosophy
Perl's motto is TMTOWTDI: "There's More Than One Way To Do It". The language gives you many ways to express the same idea so you can pick the one that reads best. The flip side is that Perl code can become cryptic if you are not careful, so this course always prefers the clear version.
use strict;
use warnings;
my @langs = ("C", "sed", "awk", "shell");
# Three ways to print the same list
print "Perl borrowed from: @langs\n";
print "Perl borrowed from: ", join(", ", @langs), "\n";
foreach my $lang (@langs) {
print "- $lang\n";
}Perl borrowed from: C sed awk shell
Perl borrowed from: C, sed, awk, shell
- C
- sed
- awk
- shell
Another of Wall's ideas: Perl is designed like a natural language. Words can mean different things in different contexts, and the same expression behaves differently depending on whether Perl expects one value or a list. You will meet context early, because it explains many Perl surprises.
What you will learn
This course follows the classic path of perlintro and Learning Perl:
- Basics: scalars, numbers, strings, operators, truth.
- Collections: arrays, hashes,
map/grep, context. - Control flow and subroutines, including modern signatures.
- References and nested data structures.
- Regular expressions, Perl's superpower.
- Text work: string functions,
sprintf, sorting, files, here-docs. - Program structure: scope, packages, objects, error handling, core modules.
- Practice: one-liners, exercises and a mini log-report project.
Tip: Every
perl runexample on this site runs on a real Perl 5.42 interpreter. Change the code and press Run to experiment.
Test yourself
Who created Perl?
- Guido van Rossum
- Larry Wall
- Dennis Ritchie
- Brendan Eich
What does the motto TMTOWTDI stand for?
- The Most Typical Way To Do It
- There's More Than One Way To Do It
- Text Matching Takes Only Ten Dollars Instead
- There's Many Tools With Different Interfaces
What happened to Perl 6?
- It replaced Perl 5 everywhere
- It was cancelled before release
- It was renamed Raku and is a separate language
- It became Perl 5.36