Skip to content

Perl Tutorials — Complete Beginner to Advanced Guide

In this tutorial series, you'll learn Perl from the ground up. Perl is a highly expressive scripting language designed for text processing and system administration -- combining shell power with the most advanced built-in regex engine.

1. What is Perl?
History, philosophy, TMTOWTDI
2. Setup
Install, perlbrew, first script
3. Scalars
Numbers, strings, undef
4. Arrays
List context, operations, slicing
5. Hashes
Key-value pairs, exists, delete
6. Regular Expressions
Match, substitution, flags
7. Subroutines
sub, my, return, prototypes
8. File I/O
open, read, write, slurp
9. CPAN
cpan, cpanm, finding modules
10. OOP with Moose
Classes, attributes, roles
11. DBI
Database interface, SQL
12. CGI
Web scripting, forms, PSGI
13. Mojolicious
Real-time web framework
14. Dancer2
Minimal web framework
15. One-Liners
-e, -n, -p, -a, command-line
16. Context
Scalar vs list, void context
17. References
Array ref, hash ref, nested
18. Packages
package, our, export
19. Modules
use, require, @INC, best practices
20. Special Variables
$_, $!, $/, $., $|
21. String Functions
split, join, substr, index
22. List Functions
grep, map, sort
23. Sorting
Default, custom, Schwartzian
24. map and grep
Transformation, filtering
25. Formatting
printf, sprintf, format
26. Error Handling
die, warn, eval, Try::Tiny
27. Testing
Test::Simple, TAP, prove
28. Networking
Socket, LWP, web scraping
29. Process Management
system, exec, fork, signals
30. Mini Projects
Log analyzer, report gen, scraper

Let's begin with Lesson 1.

Published Topics

Perl Guide — What is Perl? Text Processing and System Administration

Perl is a highly expressive scripting language designed for text processing and system administration, combining shell scripting power with the most advanced built-in regex engine.

✓ Live

Perl Setup Guide — Install Perl and Run Your First Script

Perl installation covers downloading the interpreter, setting up perlbrew for version management, configuring CPAN clients, and writing your first script.

✓ Live

Perl Scalars Guide — Numbers, Strings, and the Undef Value

Perl scalars are single values representing numbers, strings, or undef, with automatic type conversion and variable interpolation in double-quoted strings.

✓ Live

Perl Arrays Guide — Ordered Lists of Scalars and Array Operations

Perl arrays are ordered lists of scalars accessed by index, supporting operations like push, pop, shift, unshift, splice, and conversion between scalar and list context.

✓ Live

Perl Hashes Guide — Key-Value Data Structures and Hash Operations

Perl hashes (%hash) are unordered collections of key-value pairs with fast lookup, supporting operations like keys, values, exists, delete, and complex nested structures.

✓ Live

Perl Regular Expressions Guide — Pattern Matching and Text Processing

Perl has the most powerful built-in regex engine of any mainstream language, with match (m//), substitution (s///), and advanced features like captures and flags.

✓ Live

Perl Subroutines Guide — Functions, Parameters, and Return Values

Perl subroutines use the sub keyword with @_ for parameters, explicit return statements, and support for prototypes, variable arguments via shift, and passing references for efficiency.

✓ Live

Perl File I/O Guide — Reading, Writing, and File Operations

Perl file I/O uses open with modes (< > >>), diamond operator <>, file handles, and strict/warnings for robust file reading, writing, and error handling in production scripts.

✓ Live

Perl Control Flow Guide — if, unless, given/when, and Conditional Logic

Perl control flow includes if/elsif/else, unless for negative conditions, given/when (experimental) for switch-like matching, and postfix modifiers for concise conditional statements.

✓ Live

Perl Loops Guide — while, for, foreach, and Iteration Control

Perl loops include while and until for conditional iteration, for (C-style) and foreach for list iteration, with next, last, and redo for loop control within any block.

✓ Live

Perl I/O Operators Guide — readline, read, sysread, and seek Operations

Perl I/O operators go beyond basic open with readline (<>) for line input, read for fixed-size binary reads, sysread for unbuffered I/O, and seek/tell for random access.

✓ Live

Perl References Guide — Scalar, Array, and Hash Reference Operations

Perl references are scalar values pointing to other data types, created with backslash (\) and square brackets [], enabling complex data structures like arrays of arrays and hashes of hashes.

✓ Live

Perl Packages Guide — Namespaces, Symbol Tables, and Scope Control

Perl packages organize code into namespaces with the package keyword, controlling symbol visibility through lexical (my) and package (our) scoping and fully qualified names (Package::variable).

✓ Live

Perl Modules Guide — Creating, Exporting, and Using CPAN Modules

Perl modules are .pm files with package declarations and Exporter for symbol export, loaded via require or use, with CPAN providing over 200,000 reusable modules for any task.

✓ Live

Perl OOP Guide — Object-Oriented Programming with Bless and Methods

Perl OOP uses bless to associate a reference with a class package, defining methods as subroutines that receive the object ($self) as the first argument via the arrow (->) syntax.

✓ Live

Perl Moose Guide — Modern OOP Framework with Type System and Roles

Perl Moose is a postmodern OOP framework providing has (attributes), extends (inheritance), with (roles), type validation, builder methods, triggers, and method modifiers for robust class design.

✓ Live

Perl Context Guide — Scalar vs List Context and wantarray

Perl context determines what a function returns based on how it's called -- scalar context returns a single value, list context returns multiple values, and void context discards results.

✓ Live

Perl String Functions Guide — Index, Substr, Split, Join, and Formatting

Perl string functions include index and rindex for search, substr for extraction and replacement, split and join for delimiter operations, and sprintf/chr/ord for formatting and character conversion.

✓ Live

Perl Sorting Guide — Custom Comparisons, Stable Sort, and Advanced Techniques

Perl sort uses a comparison block returning -1, 0, or 1 with $a and $b, supporting string (cmp) and numeric (<=>) comparison, Schwartzian transform for efficiency, and sort on hash values.

✓ Live

Perl Map and Grep Guide — List Transformation and Filtering Functions

Perl map transforms lists by applying an expression to each element, grep filters lists by a boolean condition, and together they enable functional-style data processing without explicit loops.

✓ Live

Perl DBI Guide — Database Access with DBI and SQL Integration

Perl DBI (Database Interface) provides database-independent access with connect, prepare, execute, fetch, and commit/rollback -- supporting MySQL, PostgreSQL, SQLite, and Oracle through DBD drivers.

✓ Live

Perl Command Line Guide — One-Liners and CLI Scripting Techniques

Perl command-line flags -e (inline code), -p (print loop), -n (non-print loop), -a (auto-split), -F (field delimiter), -i (in-place edit) make Perl the king of one-liner text processing.

✓ Live

Perl Debugging Guide — Perl Debugger, Data Inspection, and Diagnostic Tools

Perl debugging uses the built-in debugger (-d flag), Data::Dumper for variable inspection, Carp for structured error messages, and strict/warnings for compile-time error detection.

✓ Live

Perl Testing Guide — Test::More, TAP, and Testing Best Practices

Perl testing uses Test::More with ok, is, isnt, like, and cmp_ok for assertions, producing TAP-compliant output runnable with prove or make test for automated test suites.

✓ Live

Perl CPAN Guide — Module Installation, cpanm, and Dependency Management

Perl CPAN (Comprehensive Perl Archive Network) hosts over 200,000 modules installed via cpan or cpanm, with local::lib for user-level installs and Carton for application dependency management.

✓ Live

Perl Unicode Guide — Encoding, Decoding, and Character Handling

Perl Unicode support uses decode/encode with Encode module, utf8 and open pragmas, and the -C flag for full Unicode awareness in file I/O, strings, and regular expressions.

✓ Live

Perl Signal Handling Guide — %SIG, Signal Traps, and Process Communication

Perl signal handling uses %SIG hash to trap signals (INT, TERM, PIPE, USR1, USR2) with coderefs, enabling graceful shutdown, custom behavior, and inter-process communication in scripts.

✓ Live

Perl Process Management Guide — Fork, Exec, and Process Control

Perl process management uses fork for creating child processes, exec for replacing the current process, wait and waitpid for collecting child exit status, and system/backticks for command execution.

✓ Live

Perl File Operations Guide — File::Basename, File::Copy, and Path Management

Perl file operations beyond open include File::Basename for path parsing, File::Copy for cp/mv, File::Path for mkdir/rmtree, File::Find for directory traversal, and glob for filename matching.

✓ Live

Perl Memory Management Guide — Reference Counting, Leaks, and Optimization

Perl memory management uses reference counting with circular reference detection, weak references via Scalar::Util::weaken, and tools like Devel::Peek and Devel::Cycle for leak detection.

✓ Live

All 30 topics in Perl Tutorials — Complete Beginner to Advanced Guide are published.