Leanpub Header

Skip to main content

Modern Perl Programming

A Complete Guide from Fundamentals to Production

This book is 100% completeLast updated on 2026-07-03

Modern Perl Programming is a practical guide to writing clean, maintainable Perl code. It covers the language from the fundamentals to object-oriented programming, regular expressions, databases, and web development with Mojolicious. Whether you are learning Perl for the first time or working with an existing codebase, this book will help you build reliable applications with confidence.

Minimum price

$19.00

$29.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
About

About

About the Book

This book is a comprehensive guide to the Perl programming language for developers of all experience levels. You will learn Perl's syntax and data model, master its legendary regex engine, build object-oriented applications with modern Corinna classes, connect to databases, create real-time web applications with Mojolicious, and deploy production-grade systems. With over 47,000 distributions on CPAN, Perl remains a powerful tool for text processing, system administration, data engineering, and full-stack web development. Whether you are a seasoned programmer exploring a new language or a developer who needs to maintain legacy Perl code, this book will give you the skills and confidence to write clean, efficient, secure Perl code that works in production today.

Share this book

Author

About the Author

Steve T. Publications

Steve T. is a cybersecurity leader, researcher, and engineer with more than 20 years of experience across application security, infrastructure security, vulnerability management, software development, and secure engineering practices. Having built his career alongside the growth of the modern internet, he has worked through multiple generations of technology, evolving security threats, and changing development methodologies.

He is currently part of the advanced research organization at a leading cybersecurity company, where he focuses on emerging threats, security innovation, and the practical application of research. His work involves investigating new attack techniques, evaluating emerging technologies, conducting deep technical analysis, and helping organizations better understand and manage complex security risks.

In addition to his research responsibilities, Steve leads a team of senior engineers and subject matter experts who create technical books, training programs, and educational resources for security professionals. Through this work, he helps engineers, developers, architects, and security practitioners strengthen their skills and build more secure systems.

Steve's technical expertise spans software development, reverse engineering, web application security, penetration testing, security architecture, incident response, vulnerability research, operating system internals, and secure software development. His ability to analyze systems at both the source code and binary levels enables him to bridge the worlds of software engineering, security research, and practical defense.

Over the course of his career, Steve has worked with organizations across a wide range of industries, helping them identify, assess, and remediate security weaknesses in critical applications and infrastructure. He is recognized for combining deep technical expertise with a pragmatic approach to security, focusing on solutions that are effective, sustainable, and aligned with business goals.

Through his work in research, engineering, leadership, and education, Steve continues to contribute to the advancement of cybersecurity and the development of secure, resilient technology systems.

Contents

Table of Contents

A Complete Guide from Fundamentals to Production

Introduction: The Language That Built the Internet

Chapter 1: What Is Perl and Why Does It Matter?

  1. The Origins of Perl: Larry Wall’s Vision
  2. Where Perl Lives Today
  3. Perl vs. Python vs. Ruby: A Fair Comparison
  4. The Perl Ecosystem at a Glance
  5. Setting Up Your Development Environment
  6. Hands-On Exercise 1.1: Your First Perl Program
  7. Mini-Project: Log File Analyzer
  8. Summary

Chapter 2: Perl Fundamentals and Syntax

  1. Scalars, Sigils, and Variable Naming
  2. Lists, Arrays, and Hashes (The Big Three)
  3. Operators: Arithmetic, String, Comparison, Logical
  4. Control Structures: if, unless, given/when
  5. Subroutines: Defining, Calling, and Signatures
  6. Hands-On Exercise 2.1: Temperature Converter
  7. Mini-Project: Word Frequency Counter
  8. Summary

Chapter 3: The Perl Regex Engine

  1. Basic Pattern Matching and the =~ Operator
  2. Quantifiers, Anchors, and Character Classes
  3. Grouping, Capturing, and Backreferences
  4. Advanced Features: Lookarounds, Atomic Groups, Possessive Quantifiers
  5. Unicode Support and Extended Character Classes
  6. Regex Performance Pitfalls and Optimization
  7. Hands-On Exercise 3.1: Email Validator
  8. Mini-Project: Log Parser with Advanced Regex
  9. Summary

Chapter 4: File I/O and Text Processing

  1. Opening, Reading, and Writing Files
  2. The Diamond Operator and ARGV Handling
  3. Directory Operations and File::Find
  4. Text Manipulation: split, join, substr, sprintf
  5. Line-by-Line Processing Patterns
  6. Hands-On Exercise 4.1: CSV Parser
  7. Mini-Project: Configuration File Parser
  8. Summary

Chapter 5: References, Data Structures, and Complex Objects

  1. What Are References? Understanding Scalar Refs
  2. Array and Hash References
  3. Nested Data Structures and Traversal
  4. The Data::Dumper and Dumper Alternatives
  5. Working with Code References and Closures
  6. Hands-On Exercise 5.1: Nested Data Structure Builder
  7. Mini-Project: INI to JSON Converter
  8. Summary

Chapter 6: Packages, Modules, and the CPAN Ecosystem

  1. Packages and Namespaces in Perl
  2. Creating Your First Module
  3. Using CPAN: cpan, cpanminus, and Carton
  4. Module Development Best Practices (Minilla)
  5. CPAN Security
  6. Hands-On Exercise 6.1: Create a Utility Module
  7. Mini-Project: CPAN Module Finder
  8. Summary

Chapter 7: Object-Oriented Programming with Corinna

  1. Perl OOP Before Corinna: Hash-Based Objects
  2. Introduction to Corinna (v5.38+)
  3. Defining Classes, Fields, and Methods
  4. Inheritance, Roles, and Composition
  5. Object Serialization and Lifecycle
  6. Hands-On Exercise 7.1: Library System
  7. Mini-Project: Task Manager with OOP
  8. Summary

Chapter 8: Error Handling and Testing

  1. Die, Carp, and Warning Strategies
  2. try/catch Blocks (Stable in v5.40)
  3. Custom Exception Classes
  4. Testing Fundamentals: TAP and Test::More
  5. Test2 Suite and Code Coverage
  6. Hands-On Exercise 8.1: Testing a Calculator Module
  7. Mini-Project: Testing Framework for Configuration Parser
  8. Summary

Chapter 9: Database Connectivity with DBI

  1. The DBI Architecture: Connectors, Handles, Drivers
  2. Connecting to SQLite, MySQL, PostgreSQL
  3. Prepared Statements and Placeholders
  4. Transaction Management and Error Recovery
  5. ORM Alternatives: DBIx::Class and Slicker
  6. Hands-On Exercise 9.1: Simple Database Application
  7. Mini-Project: Blog Database
  8. Summary

Chapter 10: Web Development with Perl

  1. The PSGI/Plack Foundation
  2. Mojolicious: Full-Stack Real-Time Framework
  3. Dancer3 for Rapid Prototyping
  4. RESTful APIs with JSON and Validation
  5. Deployment Strategies
  6. Hands-On Exercise 10.1: Simple Web Application
  7. Mini-Project: Blog API
  8. Summary

Chapter 11: Concurrency, Networking, and Automation

  1. Perl Threads (ithreads): Basics and Limitations
  2. Coro: The “Real” Threads in Perl
  3. AnyEvent and Event-Driven Programming
  4. Network Programming: Sockets and HTTP Clients
  5. System Administration Automation
  6. Hands-On Exercise 11.1: Concurrent Web Scraper
  7. Mini-Project: System Monitor
  8. Summary

Chapter 12: Security, Performance, and Modern Perl Features

  1. Taint Mode and Input Validation
  2. SQL Injection Prevention with DBI Placeholders
  3. XSS Prevention and Output Escaping
  4. Profiling with Devel::NYTProf and Benchmarking
  5. Performance Optimization Techniques
  6. Modern Perl v5.40+ Features
  7. Hands-On Exercise 12.1: Secure Web Form
  8. Mini-Project: Performance Benchmark Suite
  9. Summary

Capstone Project: Production-Grade Blog Platform

  1. Project Requirements
  2. Implementation Outline
  3. Testing

Conclusion

References

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub