About this Tutorial and eBook

The Perl Maven tutorial will teach you the basics of the Perl programming language. You'll be able to write simple scripts, analyze log files and read and write CSV files. Just to name a few common tasks.

You'll learn how to use CPAN and several specific CPAN modules.

It will be a good foundation for you to build on.

If you are interested in getting updated when new parts are published, please subscribe to the newsletter.

There is also an e-book version of the material available for purchase. In addition to the tutorial, the eBook also includes some material that is only available pro subscribers.


Financial supporters of the Perl Tutorial

Extended eBook

An extended version of the Perl Tutorial is available as an eBook. It contains all the materials from the free tutorial and a number of additional articles that are only available to the Pro subscribers.

Brand new or Legacy?

In every tutorial and in every book there is a tension between teaching the most modern techniques or teach how the legacy code works.

The most recent techniques will only be available to people who can use the most recent version of Perl. They are probably only relevant to new projects. People who need to use older versions of Perl or who cannot install modern CPAN modules will just get frustrated seeing all the nice stuff, but not able to use it.

The old techniques on the other hand will allow you to maintain existing applications and will allow you to write new applications on both old and new versions of Perl. The drawback here is that in many cases you might need to write more code, sometimes a lot more code, than you would if you used a recent version of Perl and recent CPAN modules.

This tutorial, and this eBook tries to provide a solution to this dilemma by providing both. Telling you about the alternative options and giving advice which one to use in which situation.

Video series

There is a free video course that includes over 210 screencasts, a total of more than 5 hours of video. In addition to presenting the material it also provides explanations to the solutions of all the exercise.

There is also a free advanced Perl course.

Free on-line Beginner Perl Maven tutorial

In this tutorial you are going to learn how to use the Perl 5 programming language to get your job done.

You will learn both general language features, and extensions or libraries or as the Perl programmers call them modules. We will see both standard modules, that come with perl and 3rd-party modules, that we install from CPAN.

When it is possible I'll try to teach things in a very task oriented way. I'll draw up tasks and then we'll learn the necessary tools to solve them. Where possible I'll also direct you to some exercises you can do to practice what you have learned.


  1. Install Perl, print Hello World, Safety net (use strict, use warnings)
  2. #!/usr/bin/perl - the hash-bang line
  3. Editors, IDEs, development environment for Perl
  4. Getting Help
  5. Perl on the command line
  6. Core Perl documentation, CPAN module documentation
  7. POD - Plain Old Documentation
  8. Debugging Perl scripts


  1. Common warnings and error messages
  2. Prompt, read from STDIN, read from the keyboard
  3. Automatic string to number conversion
  4. Conditional statements: if
  5. Boolean (true and false) values in Perl
  6. Numerical operators
  7. String operators
  8. undef, the initial value and the defined function
  9. Strings in Perl: quoted, interpolated and escaped
  10. Here documents
  11. Scalar variables
  12. Comparing scalars
  13. String functions: length, lc, uc, index, substr
  14. Number Guessing game (rand, int)
  15. Perl while loop
  16. Scope of variables in Perl
  17. Boolean Short circuit


  1. exit
  2. Standard Output, Standard Error and command line redirection
  3. warn
  4. die
  5. Writing to files
  6. Appending to files
  7. Open and read from files using Perl
  8. Don't open files in the old way
  9. Binary mode - reading and writing binary files
  10. eof, end of file in Perl
  11. tell
  12. seek
  13. truncate
  14. Slurp mode

Lists and Arrays

  1. Perl foreach loop
  2. The for loop in Perl
  3. Lists in Perl
  4. Using Modules
  5. Arrays in Perl
  6. Process command line parameters @ARGV
  7. Process command line parameters using Getopt::Long
  8. Advanced usage of Getopt::Long for accepting command line arguments
  9. split
  10. How to read and process a CSV file? (split, Text::CSV_XS)
  11. join
  12. The year of 19100 (time, localtime, gmtime) and introducing context
  13. Context sensitivity in Perl
  14. Reading from a file in scalar and list context
  15. STDIN in scalar and list context
  16. Sorting arrays in Perl
  17. Sorting mixed strings
  18. Unique values in an array in Perl
  19. Manipulating Perl arrays: shift, unshift, push, pop
  20. Stack
  21. Queue
  22. reverse
  23. The ternary operator
  24. Loop controls: next and last
  25. min, max, sum using List::Util
  26. qw - quote word


  1. Subroutines and Functions in Perl
  2. Passing multiple parameters to a function
  3. Variable number of parameters
  4. Returning a list, returning an array
  5. Recursive subroutines


  1. Perl Hashes (dictionary, associative array, look-up table)
  2. Creating hash from an array
  3. Perl hash in scalar and list context
  4. exists hash element
  5. delete hash elements
  6. Sorting a hash
  7. Count word frequency in a text file

Regular Expressions

  1. Introduction to Regular Expressions in Perl
  2. Regex: character classes
  3. Regex: special character classes
  4. Regex: quantifiers
  5. Regex: Greedy and non-greedy match
  6. Regex: Grouping and capturing
  7. Regex: Anchors
  8. Regex options and modifiers
  9. Substitutions (search and replace)
  10. trim - remove leading and trailing spaces
  11. Perl 5 Regex Cheat sheet

Shell related functionality

  1. Perl -X operators
  2. Perl pipes
  3. Unix commands: chmod, chown, cd, mkdir, rmdir, ln, ls
  4. Unix commands: pwd - current working directory
  5. Running external programs using system
  6. Capturning the output of an external program using qx or backticks
  7. Capturing output asynchronously
  8. Capturing both STDOUT and STDERR
  9. Unix commands: rm, mv, cp: How to remove, copy or rename a file with Perl
  10. Windows/DOS commands: del, ren, dir
  11. File globbing (Wildcards)
  12. Directory handles
  13. Traversing directory tree manually with recursion
  14. Traversing directory tree manually using a queue and using find.


  1. Download and install Perl (Strawberry Perl or manual compilation)
  2. Download and install Perl using Perlbrew
  3. Locating and evaluating CPAN modules
  4. Downloading and installing Perl Modules from CPAN
  5. How to change @INC to find Perl modules in non-standard locations?
  6. How to change @INC to a relative directory
  7. local::lib

Examples for using Perl

  1. How to replace a string in a file with Perl? (slurp)
  2. Reading Excel files using Perl
  3. Creating Excel files using Perl
  4. Sending e-mail using Perl
  5. CGI scripts with Perl
  6. Parsing XML files
  7. Reading and writing JSON files
  8. Database access using Perl (DBI, DBD::SQLite, MySQL, PostgreSQL, ODBC)
  9. Accessing LDAP using Perl

Common warnings and error messages

  1. Global symbol requires explicit package name ...
  2. .. also explained in Variable declaration in Perl
  3. Use of uninitialized value
  4. Bareword not allowed while "strict subs" in use
  5. Name "main::x" used only once: possible typo at ...
  6. Unknown warnings category
  7. Can't use string (...) as a HASH ref while "strict refs" in use at ... ...
  8. ... explained in Symbolic references in Perl
  9. Can't locate ... in @INC
  10. Scalar found where operator expected
  11. "my" variable masks earlier declaration in same scope
  12. Can't call method ... on unblessed reference
  13. Argument ... isn't numeric in numeric ...
  14. Can't locate object method "..." via package "1" (perhaps you forgot to load "1"?)
  15. Odd number of elements in hash assignment
  16. Possible attempt to separate words with commas
  17. Undefined subroutine ... called
  18. Useless use of hash element in void context
  19. Useless use of private variable in void context
  20. readline() on closed filehandle
  21. Possible precedence issue with control flow operator
  22. Scalar value better written as ...
  23. substr outside of string at ...
  24. Have exceeded the maximum number of attempts (1000) to open temp file/dir
  25. Deep recursion on subroutine
  26. Use of implicit split to @_ is deprecated ...

Extra articles

  1. Multi dimensional arrays
  2. Multi dimensional hashes
  3. Minimal requirement to build a sane CPAN package
  4. Statement modifiers: reversed if statements
  5. autovivification
  6. Formatted printing in Perl using printf and sprintf

From other books

  1. Splice to slice and dice arrays in Perl
  2. How to improve your Perl code

Object Oriented Perl with Moose or Moo

There is a whole series of articles on writing Object Oriented code, using the light-weight Moo OOP framework or the full-blown Moose OOP framework.

There is a corresponding video courses and the whole tutorial is available as eBook.