Perl Tutorial

This Perl tutorial teaches you Perl programming language from the scratch with practical examples.

If you’re new to Perl, this tutorial is a good start.

If you’re familiar with Perl and want to review your Perl knowledge, you’ll find some new features of the Perl language, which have been released in recent versions. This Perl tutorial is updated to version 5.24.

Powerful, stable, portable, and mature, Perl is one of the most feature-rich programming languages with over three decades of development.

Perl is portable and cross-platform. Currently, Perl can run on over 100 platforms.

Perl is good for both mission-critical large-scale projects and rapid prototyping.

Section 1. Getting Started

If you’re new to Perl…

Section 2. Basic Perl Tutorial

In this section, you’ll learn about Perl fundamentals including basic syntax, variables, operators

  • Syntax – teaches you basic syntax in Perl including values, variables, expressions, statements, blocks, comments, whitespaces, and keywords.
  • Variables – explains to you the variables, variable scopes, and variable interpolation.
  • Numbers – introduces the numbers in Perl including integer and floating-point numbers
  • String – introduces you to the strings data type and how to manipulate strings effectively.
  • Operators – guides you on commonly used operators including numeric operators, string operators, and logical operators.

Section 3. Perl Data Structures

In this section, you’ll learn about three important data structures in Perl including list, array, and hash.

  • List – introduces you to the list and how to manipulate list elements.
  • Array – learns about arrays and how to manipulate arrays effectively.
  • Hash – guides you on another compound data type called hash and shows you how to manipulate hash elements effectively.

Section 4. Flow Control

In this section, you’ll learn how to use Perl control flow statements including if/elsif/else, for/foreach, while/do while, until/do until, next,last statements. In addition, you’ll learn how to use a relatively new statement in Perl called given/when statement, which is similar to the switch case statement in C.

  • if…else – learns how to use the if…else statement to execute a block of code based on a specified condition.
  • unless – provides you with another statement to execute a block of code based on a condition.
  • given…when – introduces the given…when statement that allows you to match a value or variable against a list of values.
  • for loop – learns how to iterate over elements of a list.
  • while – shows you how to execute a block of code based on a condition.
  • do…while – learns how to execute a block of code as long as the
  • until – learns how to execute a block of code as long as a condition is true.
  • do…until – execute a block of code repeatedly with the test condition checked at the end of each iteration.
  • next – learns how to control the flow of the loop.
  • last – shows you how to exit a loop.

Section 5. Perl Regular Expression

Regular expressions allow you to match text based on patterns. Perl regular expressions are powerful and very simple to use. In this section, you’ll learn about the basic regular expression matching techniques, character classes, alternation, grouping, substitutions, and translation.

Section 6. Perl References

Perl’s references are simple but very powerful. In this section, you’ll learn how to create array references, hash references, anonymous references, and other kinds of references. You’ll also learn how to use Perl references effectively in your programs.

Section 7. Subroutines

A large Perl program is divided into reusable units of code which are known as functions or subroutines. In this section, you’ll learn how to define subroutines, how to pass parameters to the subroutine by references and values, and how to pass an array reference to subroutines.

Section 8. Packages and modules

This section helps you understand packages and namespaces. And you’ll learn how to define a new module in Perl.

  • Modules – introduces you to modules in Perl.

Section 9. File I/O

In this section, you’ll learn how to deal with File I/O such as opening a file, reading from a file, and writing to file using file handles. You’ll also learn useful file handling techniques using the diamond operator (<>).

Section 10. Perl Databases

In this section, you’ll learn how to interact with databases using the Perl DBI module.

Section 11. Object-Oriented Programming

This section helps you understand the object and the rules of Perl’s object-oriented system. In addition, you’ll learn how to define a class and reuse it in across programs.

  • Perl OOP – learns the basic concepts of Perl objects.

Section 12. Advanced Perl tutorial

  • Perl sort – shows you various sorting techniques in Perl.

Feedback

Found a typo or mistake ❌, please report 📢 it to via the 📧 feedback form