| |
| |
Introduction | |
| |
| |
| |
What Is Perl? | |
| |
| |
Perl Today | |
| |
| |
Getting Perl | |
| |
| |
Working with Non-Windows Platforms: perlbrew | |
| |
| |
Using Windows | |
| |
| |
The Perl Community | |
| |
| |
IRC | |
| |
| |
PerlMonks | |
| |
| |
Perl Mongers | |
| |
| |
StackOverflow | |
| |
| |
Using perldoc | |
| |
| |
Understanding the Structure of perldoc | |
| |
| |
Getting Started with perldoc | |
| |
| |
Using Tutorials and FAQs | |
| |
| |
Using the perldoc -f function | |
| |
| |
Using a Terminal Window | |
| |
| |
Using the Command Line | |
| |
| |
Creating a Work Directory | |
| |
| |
Creating Hello, World! | |
| |
| |
Writing Your First Program | |
| |
| |
Shebang Lines | |
| |
| |
Summary | |
| |
| |
| |
Understanding The Cpan | |
| |
| |
CPAN and METACPAN | |
| |
| |
Finding and Evaluating Modules | |
| |
| |
Downloading and Installing | |
| |
| |
CPAN Clients | |
| |
| |
Using the CPAN.pm Client | |
| |
| |
Using the Cpanm Client | |
| |
| |
PPM | |
| |
| |
CPAN::Mini | |
| |
| |
Summary | |
| |
| |
| |
Variables | |
| |
| |
What Is Programming? | |
| |
| |
A Few Things to Note Before Getting Started | |
| |
| |
strict, warnings, and diagnostics | |
| |
| |
The my Function | |
| |
| |
Sigils | |
| |
| |
Identifiers | |
| |
| |
Scalars | |
| |
| |
Strings | |
| |
| |
Numbers | |
| |
| |
Arrays | |
| |
| |
Breaking Down the Code | |
| |
| |
Accessing Elements | |
| |
| |
Iterating over Arrays | |
| |
| |
Hashes | |
| |
| |
Accessing Elements | |
| |
| |
Iterating Over Hashes | |
| |
| |
Adding Data to Hashes | |
| |
| |
Slices | |
| |
| |
Array Slices | |
| |
| |
Hash Slices | |
| |
| |
Context | |
| |
| |
Scalar Context | |
| |
| |
List Context | |
| |
| |
Scope | |
| |
| |
my Variables | |
| |
| |
Package Variables | |
| |
| |
Strict, Warnings, and Diagnostics | |
| |
| |
strict | |
| |
| |
warnings | |
| |
| |
diagnostics | |
| |
| |
Working Without a Net | |
| |
| |
Perl�s Built-in Variables | |
| |
| |
$_ | |
| |
| |
%ENV | |
| |
| |
@ARGV | |
| |
| |
Other Special Variables | |
| |
| |
Summary | |
| |
| |
| |
Working With Data | |
| |
| |
Using Scalars | |
| |
| |
Working with Strings | |
| |
| |
Using String Operators | |
| |
| |
Scalar::Util | |
| |
| |
Numeric Builtins | |
| |
| |
Bitwise Operators | |
| |
| |
Understanding Booleans | |
| |
| |
Assignment Operators | |
| |
| |
Precedence and Associativity | |
| |
| |
Array and List Functions | |
| |
| |
Built-in Array Functions | |
| |
| |
List::Util | |
| |
| |
Built-in Hash Functions | |
| |
| |
delete() | |
| |
| |
exists() | |
| |
| |
keys() | |
| |
| |
values() | |
| |
| |
each() | |
| |
| |
Scoping Keywords | |
| |
| |
my() | |
| |
| |
local() | |
| |
| |
our() | |
| |
| |
state() | |
| |
| |
Summary | |
| |
| |
| |
Control Flow | |
| |
| |
Using the if Statement | |
| |
| |
Understanding Basic Conditionals | |
| |
| |
else/elsif/unless | |
| |
| |
The Ternary Operator ?: | |
| |
| |
for/foreach loops | |
| |
| |
Arrays | |
| |
| |
Lists | |
| |
| |
C-Style | |
| |
| |
Using while/until Loops | |
| |
| |
Lists | |
| |
| |
last/next/redo/continue | |
| |
| |
Labels | |
| |
| |
Statement Modifiers | |
| |
| |
Types of Statement Modifiers | |
| |
| |
do while/do until | |
| |
| |
given/when | |
| |
| |
Basic Syntax | |
| |
| |
The Switch Module | |
| |
| |
Summary | |
| |
| |
| |
References | |
| |
| |
References 101 | |
| |
| |
Array References | |
| |
| |
Hash References | |
| |
| |
Anonymous References | |
| |
| |
Other References | |
| |
| |
Working with References | |
| |
| |
Debugging | |
| |
| |
Copying | |
| |
| |
Slices | |
| |
| |
Summary | |
| |
| |
| |
Subroutines | |
| |
| |
Subroutine Syntax | |
| |
| |
Argument Handling | |
| |
| |
Multiple Arguments | |
| |
| |
Named Arguments | |
| |
| |
Aliasing | |
| |
| |
State Variables (Pre- and Post-5.10) | |
| |
| |
Passing a List, Hash, or Hashref? | |
| |
| |
Returning Data | |
| |
| |
Returning True/False | |
| |
| |
Returning Single and Multiple Values | |
| |
| |
wantarray | |
| |
| |
FAIL! | |
| |
| |
�Wake Up! Time to Die!� | |
| |
| |
carp and croak | |
| |
| |
eval | |
| |
| |
evalGotchas | |
| |
| |
Try::Tiny | |
| |
| |
Subroutine References | |
| |
| |
Existing Subroutines | |
| |
| |
Anonymous Subroutines | |
| |
| |
Closures | |
| |
| |
Prototypes | |
| |
| |
Argument Coercion | |
| |
| |
More Prototype Tricks | |
| |
| |
Mimicking Builtins | |
| |
| |
Forward Declarations | |
| |
| |
Prototype Summary | |
| |
| |
Recursion | |
| |
| |
Basic Recursion | |
| |
| |
Divide and Conquer | |
| |
| |
Memoization | |
| |
| |
Things to Watch For | |
| |
| |
Argument Aliasing | |
| |
| |
Scope Issues | |
| |
| |
Doing Too Much | |
| |
| |
Too Many Arguments | |
| |
| |
Summary | |
| |
| |
| |
Regular Expressions | |
| |
| |
Basic Matching | |
| |
| |
Quantifiers | |
| |
| |
Escape Sequences | |
| |
| |
Extracting Data | |
| |
| |
Modifiers and Anchors | |
| |
| |
Character Classes | |
| |
| |
Grouping | |
| |
| |
Advanced Matching | |
| |
| |
Substitutions | |
| |
| |
Lookahead/Lookbehind Anchors | |
| |
| |
Named Subexpressions (5.10) | |
| |
| |
Common Regular Expression Issues | |
| |
| |
Regexp::Common | |
| |
| |
E-mail Addresses | |
| |
| |
HTML | |
| |
| |
Composing Regular Expressions | |
| |
| |
Summary | |
| |
| |
| |
Files And Directories | |
| |
| |
Basic File Handling | |
| |
| |
Opening and Reading a File | |
| |
| |
File Test Operators | |
| |
| |
The Diamond Operator | |
| |
| |
Temporary Files | |
| |
| |
DATA as a File | |
| |
| |
binmode | |
| |
| |
Directories | |
| |
| |
Reading Directories | |
| |
| |
Globbing | |
| |
| |
Unicode | |
| |
| |
What Is Unicode? | |
| |
| |
Two Simple Rules | |
| |
| |
Lots of Complicated Rules | |
| |
| |
Useful Modules | |
| |
| |
File::Find | |
| |
| |
File::Path | |
| |
| |
File::Find::Rule | |
| |
| |
Summary | |
| |
| |
| |
Sort, Map, And Grep | |
| |
| |
Basic Sorting | |
| |
| |
Sorting Alphabetically | |
| |
| |
Sorting Numerically | |
| |
| |
Reverse Sorting | |
| |
| |
Complex Sort Conditions | |
| |
| |
Writing a sort Subroutine | |
| |
| |
Sorting and Unicode Fun! | |
| |
| |
map and grep | |
| |
| |
Using grep | |
| |
| |
Using map | |
| |
| |
Aliasing Issues | |
| |
| |
Trying to Do Too Much | |
| |
| |
Trying to Be Clever | |
| |
| |
Putting It All Together | |
| |
| |
Schwartzian Transform (aka decorate, sort, undecorate) | |
| |
| |
Guttman-Rosler Transform | |
| |
| |
Summary | |
| |
| |
| |
Packages And Modules | |
| |
| |
Namespaces and Packages | |
| |
| |
use Versus require | |
| |
| |
Package Variables | |
| |
| |
Version Numbers | |
| |
| |
Subroutines in Other Packages | |
| |
| |
Exporting | |
| |
| |
Naming Conventions | |
| |
| |
BEGIN, UNITCHECK, CHECK, INIT, and END | |
| |
| |
BEGIN blocks | |
| |
| |
END Blocks | |
| |
| |
INIT, CHECK, and UNITCHECK Blocks | |
| |
| |
Plain Old Documentation (POD) | |
| |
| |
Documentation Structure | |
| |
| |
Headings | |
| |
| |
Paragraphs | |
| |
| |
Lists | |
| |
| |
Verbatim | |
| |
| |
Miscellaneous | |
| |
| |
Creating and Installing Modules | |
| |
| |
Creating a Simple Module | |
| |
| |
Makefile.PL or Module::Build? | |
| |
| |
Summary | |
| |
| |
| |
Object Oriented Perl | |
| |
| |
What Are Objects? The �var the Personal Shopper | |
| |
| |
Three Rules of Perl OO | |
| |
| |
Class Is a Package | |
| |
| |
An Object Is a Reference That Knows Its Class | |
| |
| |
A Method Is a Subroutine | |
| |
| |
Objects - Another View | |
| |
| |
Using TV::Episode | |
| |
| |
Subclassing | |
| |
| |
Using TV::Episode::Broadcast | |
| |
| |
Class Versus Instance Data | |
| |
| |
A Brief Recap | |
| |
| |
Overloading Objects | |
| |
| |
Using UNIVERSAL | |
| |
| |
Understanding Private Methods | |
| |
| |
Gotchas | |
| |
| |
Unnecessary Methods | |
| |
| |
�Reaching Inside� | |
| |
| |
Multiple Inheritance | |
| |
| |
Summary | |
| |
| |
| |
Moose | |
| |
| |
Understanding Basic Moose Syntax | |
| |
| |
Using Attributes | |
| |
| |
Using Constructors | |
| |
| |
Understanding Inheritance | |
| |
| |
Taking Care of Your Moose | |
| |
| |
Advanced Moose Syntax | |
| |
| |
Using Type Constraints | |
| |
| |
Using Method Modifiers | |
| |
| |
Understanding and Using Roles | |
| |
| |
Exploring MooseX | |
| |
| |
Rewriting Television::Episode | |
| |
| |
Moose Best Practices | |
| |
| |
Use namespace::autoclean and Make Your Class Immutable | |
| |
| |
Never Override new() | |
| |
| |
Always Call Your Parent BUILDARGS Method | |
| |
| |
Provide Defaults if an Attribute is Not Required | |
| |
| |
Default to Read-Only | |
| |
| |
Put Your Custom Types in One Module and Give Them a Namespace | |
| |
| |
Don�t Use Multiple Inheritance | |
| |
| |
Always Consume All Your Roles at Once | |
| |
| |
Summary | |
| |
| |
| |
Testing | |
| |
| |
Basic Tests | |
| |
| |
Using Test::More | |
| |
| |
Writing Your Tests | |
| |
| |
Understanding the prove Utility | |
| |
| |
Understanding Test::More Test Functions | |
| |
| |
Using ok | |
| |
| |
Using is | |
| |
| |
Using like | |
| |
| |
Using is_deeply | |
| |
| |
Using SKIP | |
| |
| |
Using TODO | |
| |
| |
Using eval {} | |
| |
| |
Using use_ok and require_ok | |
| |
| |
Working with Miscellaneous Test Functions | |
| |
| |
Using Other Testing Modules | |
| |
| |
Using Test::Diff erences | |
| |
| |
Using Test::Exception | |
| |
| |
Using Test::Warn | |
| |
| |
Using Test::Most | |
| |
| |
Understanding xUnit Style Using Testing | |
| |
| |
Using Test::Class | |
| |
| |
A Basic Test Class | |
| |
| |
Extending a Test Class | |
| |
| |
Using Test Control Methods | |
| |
| |
Calling Parent Test Control Methods | |
| |
| |
Summary | |
| |
| |
| |
The Interwebs | |
| |
| |
A Brief Introduction to HTTP | |
| |
| |
Plack | |
| |
| |
Hello, World! | |
| |
| |
Handling Parameters | |
| |
| |
Templates | |
| |
| |
Handling POST Requests | |
| |
| |
Sessions | |
| |
| |
Web Clients | |
| |
| |
Extracting Links from Web Pages | |
| |
| |
Extracting Comments from Web Pages | |
| |
| |
Filling Out Forms Programmatically | |
| |
| |
Summary | |
| |
| |
| |
Databases | |
| |
| |
Using the DBI | |
| |
| |
Connecting to a Database | |
| |
| |
Using SQLite | |
| |
| |
Using DBD::SQLite | |
| |
| |
Selecting Basic Data | |
| |
| |
Using SELECT Statements | |
| |
| |
Using Bind Parameters | |
| |
| |
Inserting and Updating Data | |
| |
| |
Creating Transactions | |
| |
| |
Handling Errors | |
| |
| |
Summary | |
| |
| |
| |
Plays Well With Others | |
| |
| |
The Command Line | |
| |
| |
Reading User Input | |
| |
| |
Handling Command-Line Arguments | |
| |
| |
perlrun | |
| |
| |
Other Programs | |
| |
| |
Running an External Program | |
| |
| |
Reading Another Program�s Output | |
| |
| |
Writing to Another Program�s Input | |
| |
| |
STDERR | |
| |
| |
Summary | |
| |
| |
| |
Common Tasks | |
| |
| |
Using CSV Data | |
| |
| |
Reading CSV Data | |
| |
| |
Writing CSV Data | |
| |
| |
Understanding Basic XML | |
| |
| |
Reading CSV Data | |
| |
| |
Writing CSV Data | |
| |
| |
Handling Dates | |
| |
| |
Using the DateTime Module | |
| |
| |
Using Date::Tiny and DateTime::Tiny | |
| |
| |
Understanding Your Program | |
| |
| |
Using the Debugger | |
| |
| |
Profiling | |
| |
| |
Perl::Critic | |
| |
| |
Summary | |
| |
| |
| |
The Next Steps | |
| |
| |
What Next? | |
| |
| |
What This Book Covers | |
| |
| |
What This Book Leaves Out | |
| |
| |
Understanding Object-Relational Mappers | |
| |
| |
Understanding DBIx::Class | |
| |
| |
Understanding Basic DBIx::Class Usage | |
| |
| |
Understanding the Pros and Cons of an ORM | |
| |
| |
Using DBIx::Class::Schema::Loader | |
| |
| |
Using the Template Toolkit | |
| |
| |
Why Use Templates? | |
| |
| |
An Introduction to Template Toolkit | |
| |
| |
Using Catalyst to Build Apps | |
| |
| |
The Beauty of MVC | |
| |
| |
Setting Up a Catalyst Application | |
| |
| |
Using Catalyst Views | |
| |
| |
Using Catalyst Models | |
| |
| |
Using Catalyst Controllers | |
| |
| |
CRUD: Create, Read, Update, and Delete | |
| |
| |
Summary | |
| |
| |
Appendix: Answers To Exercises | |
| |
| |
Index | |