A Complete Guide from Fundamentals to Production
Introduction: The Language That Built the Internet
Chapter 1: What Is Perl and Why Does It Matter?
- The Origins of Perl: Larry Wall’s Vision
- Where Perl Lives Today
- Perl vs. Python vs. Ruby: A Fair Comparison
- The Perl Ecosystem at a Glance
- Setting Up Your Development Environment
- Hands-On Exercise 1.1: Your First Perl Program
- Mini-Project: Log File Analyzer
- Summary
Chapter 2: Perl Fundamentals and Syntax
- Scalars, Sigils, and Variable Naming
- Lists, Arrays, and Hashes (The Big Three)
- Operators: Arithmetic, String, Comparison, Logical
- Control Structures: if, unless, given/when
- Subroutines: Defining, Calling, and Signatures
- Hands-On Exercise 2.1: Temperature Converter
- Mini-Project: Word Frequency Counter
- Summary
Chapter 3: The Perl Regex Engine
- Basic Pattern Matching and the =~ Operator
- Quantifiers, Anchors, and Character Classes
- Grouping, Capturing, and Backreferences
- Advanced Features: Lookarounds, Atomic Groups, Possessive Quantifiers
- Unicode Support and Extended Character Classes
- Regex Performance Pitfalls and Optimization
- Hands-On Exercise 3.1: Email Validator
- Mini-Project: Log Parser with Advanced Regex
- Summary
Chapter 4: File I/O and Text Processing
- Opening, Reading, and Writing Files
- The Diamond Operator and ARGV Handling
- Directory Operations and File::Find
- Text Manipulation: split, join, substr, sprintf
- Line-by-Line Processing Patterns
- Hands-On Exercise 4.1: CSV Parser
- Mini-Project: Configuration File Parser
- Summary
Chapter 5: References, Data Structures, and Complex Objects
- What Are References? Understanding Scalar Refs
- Array and Hash References
- Nested Data Structures and Traversal
- The Data::Dumper and Dumper Alternatives
- Working with Code References and Closures
- Hands-On Exercise 5.1: Nested Data Structure Builder
- Mini-Project: INI to JSON Converter
- Summary
Chapter 6: Packages, Modules, and the CPAN Ecosystem
- Packages and Namespaces in Perl
- Creating Your First Module
- Using CPAN: cpan, cpanminus, and Carton
- Module Development Best Practices (Minilla)
- CPAN Security
- Hands-On Exercise 6.1: Create a Utility Module
- Mini-Project: CPAN Module Finder
- Summary
Chapter 7: Object-Oriented Programming with Corinna
- Perl OOP Before Corinna: Hash-Based Objects
- Introduction to Corinna (v5.38+)
- Defining Classes, Fields, and Methods
- Inheritance, Roles, and Composition
- Object Serialization and Lifecycle
- Hands-On Exercise 7.1: Library System
- Mini-Project: Task Manager with OOP
- Summary
Chapter 8: Error Handling and Testing
- Die, Carp, and Warning Strategies
- try/catch Blocks (Stable in v5.40)
- Custom Exception Classes
- Testing Fundamentals: TAP and Test::More
- Test2 Suite and Code Coverage
- Hands-On Exercise 8.1: Testing a Calculator Module
- Mini-Project: Testing Framework for Configuration Parser
- Summary
Chapter 9: Database Connectivity with DBI
- The DBI Architecture: Connectors, Handles, Drivers
- Connecting to SQLite, MySQL, PostgreSQL
- Prepared Statements and Placeholders
- Transaction Management and Error Recovery
- ORM Alternatives: DBIx::Class and Slicker
- Hands-On Exercise 9.1: Simple Database Application
- Mini-Project: Blog Database
- Summary
Chapter 10: Web Development with Perl
- The PSGI/Plack Foundation
- Mojolicious: Full-Stack Real-Time Framework
- Dancer3 for Rapid Prototyping
- RESTful APIs with JSON and Validation
- Deployment Strategies
- Hands-On Exercise 10.1: Simple Web Application
- Mini-Project: Blog API
- Summary
Chapter 11: Concurrency, Networking, and Automation
- Perl Threads (ithreads): Basics and Limitations
- Coro: The “Real” Threads in Perl
- AnyEvent and Event-Driven Programming
- Network Programming: Sockets and HTTP Clients
- System Administration Automation
- Hands-On Exercise 11.1: Concurrent Web Scraper
- Mini-Project: System Monitor
- Summary
Chapter 12: Security, Performance, and Modern Perl Features
- Taint Mode and Input Validation
- SQL Injection Prevention with DBI Placeholders
- XSS Prevention and Output Escaping
- Profiling with Devel::NYTProf and Benchmarking
- Performance Optimization Techniques
- Modern Perl v5.40+ Features
- Hands-On Exercise 12.1: Secure Web Form
- Mini-Project: Performance Benchmark Suite
- Summary
Capstone Project: Production-Grade Blog Platform
- Project Requirements
- Implementation Outline
- Testing
