TExcelTAD
Home › Perl › Perl Intro

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".

perl · try it yourself
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.

perl · try it yourself
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:

  1. Basics: scalars, numbers, strings, operators, truth.
  2. Collections: arrays, hashes, map/grep, context.
  3. Control flow and subroutines, including modern signatures.
  4. References and nested data structures.
  5. Regular expressions, Perl's superpower.
  6. Text work: string functions, sprintf, sorting, files, here-docs.
  7. Program structure: scope, packages, objects, error handling, core modules.
  8. Practice: one-liners, exercises and a mini log-report project.

Tip: Every perl run example on this site runs on a real Perl 5.42 interpreter. Change the code and press Run to experiment.

Test yourself

Who created Perl?

  1. Guido van Rossum
  2. Larry Wall
  3. Dennis Ritchie
  4. Brendan Eich

What does the motto TMTOWTDI stand for?

  1. The Most Typical Way To Do It
  2. There's More Than One Way To Do It
  3. Text Matching Takes Only Ten Dollars Instead
  4. There's Many Tools With Different Interfaces

What happened to Perl 6?

  1. It replaced Perl 5 everywhere
  2. It was cancelled before release
  3. It was renamed Raku and is a separate language
  4. It became Perl 5.36