Programming · ADC-03-07

Basic Perl Programming

Basic Perl Programming is a foundation course in modern Perl, from scalars, arrays, hashes, conditions, loops and subroutines to regular expressions, file handling, CPAN modules, object-oriented Perl, databases with DBI and web applications with Mojolicious. It suits system developers, system administrators and anyone with previous experience of C or shell scripting.

Updated
From 9,450 THB / person 10,500 −10% excl. VAT 7% · group rates available
PDFDownload the course outline
  • Duration24 hours · 4 days
  • FormatOnsite / live online
  • Next roundOn request
  • CertificateIncluded

Course overview

Perl is a scripting language that excels at text processing, reading logs, converting files and writing system administration tools. It still ships with most Linux and macOS systems, and many organisations run systems written in Perl that need looking after and extending. Perl 5 continues to develop, with Perl 5.44 released in July 2026, and the modern language is far shorter and safer to write, with signatures, try/catch and say all switched on by a single use v5.40 line.

This course lays the foundations of modern Perl for people who have programmed before, from installation and tooling, scalars, arrays, hashes, conditions, loops and subroutines with signatures to regular expressions, text and file processing, references and data structures, error handling, CSV and JSON work and system administration scripts. You then write modules, use CPAN, write object-oriented Perl, connect to databases with DBI and build web applications with Mojolicious in place of old-style CGI. It finishes with a workshop that builds a tested log analysis tool. (4 days, 6 hours per day, 24 hours in total, Beginner to Intermediate level.)

What you’ll gain

  • Install current Perl and use perldoc, cpanm and local::lib
  • Write modern Perl with use v5.40, scalars, arrays, hashes, conditions and loops
  • Write subroutines with signatures and organise code into modules
  • Use regular expressions to match, substitute and extract data from text
  • Read and write files, process CSV and JSON, and write system administration scripts
  • Use references to build nested data structures and write object-oriented code
  • Connect to databases with DBI and build web applications with Mojolicious

Who this course is for

  • System developers who write or maintain Perl programs
  • System administrators who need scripts for logs, files and automation
  • Web administrators with existing systems written in Perl
  • Anyone who has programmed in C, shell or another language and is interested in Perl

Prerequisites

  • Good general skills with Windows, macOS or Linux
  • Programming fundamentals such as variables, conditions and loops
  • Experience of C, Unix shell or another language will help you progress faster
  • Basic command-line skills

Curriculum

Course Details

This is the 2026 edition of the Basic Perl Programming course. It runs for 4 days, 6 hours per day (24 hours in total, 09:00-16:00), as lectures with a lab for every topic, at Beginner to Intermediate level. The content has been rewritten for Perl 5.42 to 5.44, using perlbrew or Strawberry Perl with VS Code in place of ActivePerl and Eclipse, and modern style with use v5.40, signatures and try/catch. It drops given/when and old-style report formats, replaces CGI with Mojolicious for the web, and adds DBI, CSV, JSON and testing. Learners take home the course handbook, source code for every lab and the log analysis tool they build in the workshop.

Day 1 Language Basics and Data Types

Section 1: Perl in 2026

  • What Perl is, what it suits and where it is still used
  • Perl 5 versus Raku, and the 5.42 and 5.44 release cycle
  • perldoc, the documentation at perldoc.perl.org and MetaCPAN
  • Workshop: try one-liners with perl -e and perl -ne

Section 2: Lab: Installing Perl and Tools

  • perlbrew on Linux and macOS, and Strawberry Perl or WSL on Windows
  • VS Code with a Perl language extension
  • cpanm and local::lib for installing modules
  • Lab: Hello World with use v5.40 and say

Section 3: Lab: Syntax, Scalars and Operators

  • Statements, comments, blocks, strict and warnings
  • Numeric and string scalars, interpolation and quote operators
  • Arithmetic, comparison, logical and concatenation operators, and precedence
  • undef, defined-or (//) and chained comparisons
  • Lab: a calculator that works on user input

Section 4: Lab: Arrays and Lists

  • Declaring arrays, indexing and slices
  • push, pop, shift, unshift and splice
  • Scalar and list context
  • sort, reverse, join and a first look at wantarray
  • Lab: manage a list of names and rank scores

Section 5: Lab: Hashes

  • Key-value pairs, exists and delete
  • keys, values and multi-variable foreach loops
  • Hash slices and counting frequencies
  • Choosing between arrays and hashes for your data
  • Lab: count the most frequent words in a text file
Day 2 Control Flow, Functions and Regular Expressions

Section 6: Lab: Conditionals

  • if, elsif, else and unless
  • Postfix conditionals and the ternary operator
  • Truth in Perl, and builtin true and false
  • Alternatives to given/when using a hash of subroutines
  • Lab: grade scores and validate input

Section 7: Lab: Loops

  • while, until, for and foreach
  • last, next, redo and loop labels
  • Postfix loops and reading input line by line
  • map and grep in place of repetitive loops
  • Lab: transform and filter data with loops, map and grep

Section 8: Lab: Subroutines and Signatures

  • Declaring and calling subroutines with signatures and defaults
  • Returning scalars and lists
  • Variable scope with my, our and state
  • Anonymous subroutines and closures
  • Lab: refactor the calculator into reusable functions

Section 9: Lab: Special Variables and Built-in Functions

  • $_, @_, @ARGV, %ENV, $0 and $@
  • String functions: length, substr, index, lc, uc and sprintf
  • Numeric functions and List::Util
  • Dates and times with localtime and Time::Piece
  • Lab: a script that takes arguments and prints formatted output

Section 10: Lab: Regular Expression Basics

  • Matching with m// and the =~ operator
  • Character classes, quantifiers and anchors
  • Capturing with parentheses, $1 and named captures
  • Substituting with s/// and the i, g and x modifiers
  • Lab: validate email and phone formats and split data apart
Day 3 Text, Files and Automation

Section 11: Lab: Advanced Regex and Reporting

  • Non-greedy matching, lookahead and lookbehind
  • qr// and storing patterns for reuse
  • Finding every match with /g in list context
  • Formatting tabular reports with printf and sprintf
  • Lab: extract data from web server logs and summarise it as a report

Section 12: Lab: References and Data Structures

  • References to scalars, arrays, hashes and code
  • Anonymous arrays and hashes
  • Postfix dereferencing such as ->@* and ->%*
  • Nested structures and inspecting them with Data::Dumper
  • Lab: store staff records by department in a nested structure

Section 13: Lab: File I/O

  • Three-argument open with lexical filehandles
  • Reading, writing and appending, and :encoding(UTF-8) for Thai text
  • File test operators and binary files
  • Directories with opendir and File::Find
  • Lab: a script that finds and renames files across a folder

Section 14: Lab: Error Handling and Debugging

  • die, warn and readable error messages
  • Modern try/catch compared with the old eval idiom
  • Carp for errors raised from modules
  • The debugger with perl -d
  • Lab: make a file-reading script cope with missing files and bad data

Section 15: Lab: CSV, JSON and Admin Scripts

  • Reading and writing CSV with Text::CSV
  • JSON::PP and HTTP::Tiny for calling web APIs
  • Command-line options with Getopt::Long
  • Running system commands safely with system and qx
  • Lab: a CSV-to-JSON converter with command-line options
Day 4 Modules, OOP, Databases and the Web

Section 16: Lab: Modules and CPAN

  • package, use, require and @INC
  • Creating .pm files and exporting functions
  • Finding modules on MetaCPAN and installing them with cpanm and a cpanfile
  • Writing documentation in POD
  • Lab: move the log-reading functions into a module with POD

Section 17: Lab: Object-oriented Perl

  • Classic classes with package and bless
  • Constructors, accessors and inheritance
  • The new class, field, method and ADJUST syntax (experimental)
  • Reading existing OOP code in older systems
  • Lab: build account and transaction classes both ways

Section 18: Lab: Databases with DBI

  • DBI and DBD::SQLite
  • Placeholders to prevent SQL injection
  • fetchrow_hashref, selectall_arrayref and transactions
  • Connecting to MySQL, MariaDB or PostgreSQL
  • Lab: store log analysis results in an SQLite database

Section 19: Lab: Web Applications with Mojolicious

  • From old-style CGI to PSGI, Plack and Mojolicious
  • Mojolicious::Lite: routes, parameters and templates
  • Returning JSON for a web API
  • Running with morbo during development, and deployment options
  • Lab: a web page that shows the log report from the database

Section 20: Workshop: A Log Analysis Tool

  • Workshop: combine the module, CSV, DBI and web page into one tool
  • Write tests with Test::More and run them with prove
  • Format code with perltidy and check it with Perl::Critic
  • A checklist for modernising existing Perl scripts
  • Present your work and plan next steps

Schedule & training options

For individuals — public rounds

No public rounds are open right now. Join the waiting list and we will contact you first when the next round opens, or ask us on LINE. Or call 02-570-8449 or 088-807-9770

For organisations — in-house / private

  • Tailor the content to your team’s tools and projects
  • Your dates, at your office or live online
  • Quotation with tax ID for procurement
Corporate training quote

Instructors

Frequently asked questions

How do you search and replace text with regular expressions in Perl?

Regular expressions are built into Perl. Use the =~ operator with m// to match a pattern, for example if ($line =~ /error/i) checks for the word error in any case, and s/// to substitute text, for example s/\s+/ /g collapses runs of whitespace into a single space. Parts of the pattern in brackets are captured into $1, $2 and so on, or you can name them with named captures and read them from %+.

What is the difference between arrays and hashes in Perl?

An array starts with the @ sigil, holds an ordered list and is accessed by position starting at 0, for example $names[0]. A hash starts with %, stores key-value pairs and is accessed by key, for example $stock{apple}, which makes it ideal for lookups and counting. In current Perl you can loop through the pairs of a hash neatly with foreach my ($key, $value) (%stock).

Is Perl still being developed, and which version should I use?

Perl 5 still has a new release every year. The latest stable version is Perl 5.44, released in July 2026, and 5.42 continues to receive security fixes. On Linux and macOS you can install the latest version alongside the system Perl with perlbrew, and on Windows you can use Strawberry Perl or WSL. Starting a script with use v5.40 switches on strict, warnings, say, signatures and try/catch in one go.

Who is the Basic Perl Programming course for, and what should I know beforehand?

It suits system developers who write or maintain Perl programs, system administrators who need scripts for logs and automation, and web administrators with existing Perl systems. You should be comfortable with a computer and basic command-line use and have programming fundamentals, and previous experience of C or Unix shell scripting will help you move faster.

What will I be able to do after the Basic Perl Programming course?

You will be able to write modern Perl with scalars, arrays, hashes, conditions, loops and subroutines with signatures, process text and produce reports with regular expressions, read and write files, CSV and JSON, write system administration scripts, use references, organise code into modules and install modules from CPAN, write object-oriented Perl, connect to databases with DBI and build web applications with Mojolicious. Participants who complete the training receive a Certificate of Completion with its own number, which can be verified online.

Which software is used on the Basic Perl Programming course?

You use Perl 5.42 or 5.44, installed with perlbrew on Linux and macOS, or Strawberry Perl or WSL on Windows. Code is written in Visual Studio Code with a Perl language extension, and modules such as DBI, DBD::SQLite, Text::CSV and Mojolicious are installed from CPAN with cpanm. Everything is free to use.