Perl Introduction

From WikiOD

Remarks[edit | edit source]

Perl is the camel of languages: useful, but not always beautiful. It has rather good documentation of its own which can be accessed using the perldoc command from your shell/command prompt. It's also available online at

Versions[edit | edit source]

Version Release Notes Release Date
1.000 1987-12-18
2.000 1988-06-05
3.000 1989-10-18
4.000 1991-03-21
5.000 1994-10-17
5.001 1995-05-13
5.002 1996-02-29
5.003 1996-06-25
5.004 perl5004delta 1997-05-15
5.005 perl5005delta 1998-07-22
5.6.0 perl56delta 2000-03-22
5.8.0 perl58delta 2002-07-18
5.8.8 perl581delta,








5.10.0 perl5100delta 2007-12-18
5.12.0 perl5120delta 2010-04-12
5.14.0 perl5140delta 2011-05-14
5.16.0 perl5160delta 2012-05-20
5.18.0 perl5180delta 2013-05-18
5.20.0 perl5200delta 2014-05-27
5.22.0 perl5220delta 2015-06-01
5.24.0 perl5240delta 2016-05-09
5.26.0 perl5260delta 2017-05-30

Getting started with Perl[edit | edit source]

Perl tries to do what you mean:

print "Hello World\n";

The two tricky bits are the semicolon at the end of the line and the \n, which adds a newline (line feed). If you have a relatively new version of perl, you can use say instead of print to have the carriage return added automatically:


use feature 'say';
say "Hello World";

The say feature is also enabled automatically with a use v5.10 (or higher) declaration:

use v5.10;
say "Hello World";

It's pretty common to just use perl on the command line using the -e option:

$ perl -e 'print "Hello World\n"'
Hello World

Adding the -l option is one way to print newlines automatically:

$ perl -le 'print "Hello World"'
Hello World


If you want to enable new features, use the -E option instead:

$ perl -E 'say "Hello World"'
Hello World

You can also, of course, save the script in a file. Just remove the -e command line option and use the filename of the script: perl For programs longer than a line, it's wise to turn on a couple of options:

use strict;
use warnings;

print "Hello World\n";

There's no real disadvantage other than making the code slightly longer. In exchange, the strict pragma prevents you from using code that is potentially unsafe and warnings notifies you of many common errors.

Notice the line-ending semicolon is optional for the last line, but is a good idea in case you later add to the end of your code.

For more options how to run Perl, see perlrun or type perldoc perlrun at a command prompt. For a more detailed introduction to Perl, see perlintro or type perldoc perlintro at a command prompt. For a quirky interactive tutorial, Try Perl.