Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Tom Christiansen, brian d foy, Larry Wall, Jon Orwant Ph.D.

Rating No ratings yet

Adopted as the undisputed Perl bible soon after the first edition appeared in 1991, Programming Perl is still the go-to guide for this highly practical language. Perl began life as a super-fueled text processing utility, but quickly evolved into a general purpose programming language that’s helped hundreds of thousands of programmers, system administrators, and enthusiasts, like you, get your job done. In this much-anticipated update to «the Camel,» three renowned Perl authors cover the language up to its current version, Perl 5.14, with a preview of features in the upcoming 5.16. In a world where Unicode is increasingly essential for text processing, Perl offers the best and least painful support of any major language, smoothly integrating Unicode everywhere—including in Perl’s most popular feature: regular expressions. Important features covered by this update include: New keywords and syntax I/O layers and encodings New backslash escapes Unicode 6.0 Unicode grapheme clusters and properties Named captures in regexes Recursive and grammatical patterns Expanded coverage of CPAN Current best practices

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
# Programming Perl: The Camel Book Guide ## 【One-Line Pitch】 The definitive reference for Perl 5.14, covering everything from basic syntax to advanced Unicode-aware regular expressions—essential reading for programmers, system administrators, and anyone who needs powerful text processing and scripting capabilities. ## 【Book Arc】 - **Opening (~0%–9%)**: Introduces Perl's philosophy as a practical, evolving language, explains the book's conventions (code examples, shell prompts), and establishes the modern Perl baseline with `use v5.14` and the `say` keyword. - **Early (~9%–19%)**: Covers Perl's fundamental data model—scalars, arrays, and hashes—explaining how these three types form the foundation for all Perl programming, including negative array indexing and hash key/value access. - **Early (~19%–28%)**: Delves into operators and expressions, including precedence rules, associativity, and the smartmatch operator (`~~`) for sophisticated comparisons between data structures. - **Early (~28%–34%)**: Explores statements and declarations, including the `given`/`when` construct, scoping rules, packages, and pragmas like `strict` that shape modern Perl coding practices. - **Middle (~34%–47%)**: Focuses on pattern matching and regular expressions—Perl's signature feature—covering greedy vs. minimal matching, character classes, Unicode properties, and the crucial "leftmost" matching principle. ## 【Key Takeaways】 - **Perl's three data types—scalars, arrays, and hashes—form the complete foundation** (Early): A scalar holds a single value, arrays provide ordered access via integer indices (including negative ones counting from the end), and hashes offer key/value lookup by string. Understanding these types eliminates the type complexity found in languages like C. - **Context determines behavior in Perl** (Early): Whether code runs in scalar or list context fundamentally changes how expressions evaluate—assigning to `@x` versus `$x` triggers different behaviors. This context sensitivity is central to Perl's flexibility but requires conscious attention. - **Operator precedence follows mathematical conventions but adds Perl-specific rules** (Early): Multiplication binds tighter than addition (`2 + 3 * 4` yields 14), but Perl's table includes unique operators like `~~` (smartmatch) and `x` (repetition). Left vs. right associativity matters for chains like exponentiation. - **The smartmatch operator (`~~`) enables sophisticated structural comparisons** (Early): It can check deep array equality, test whether one array's elements appear in another, or verify hash key sets—useful for validating data structures like required fields in records. - **Modern Perl requires `use v5.14` to enable contemporary features** (Early): This version declaration activates `strict` and enables `say`, which appends newlines automatically. The book assumes this baseline throughout, making it essential for following examples. - **Regular expression matching prioritizes leftmost over longest** (Middle): When multiple matches exist, the earliest starting position always wins; greedy vs. minimal quantifiers only break ties when matches begin at the same point. This principle explains surprising results with patterns like `/e(.*?)e/`. - **Unicode support is deeply integrated into pattern matching** (Middle): Modifiers like `/u` enable Unicode semantics, case-insensitive matching handles multi-case characters (like Greek sigma variants), and character classes recognize Unicode properties beyond ASCII. ## 【Reading Tips】 - **Skim the front matter** (~0%–9%): The conventions section explains code formatting and shell prompts—useful reference but not core content. Jump to Chapter 1 for the real substance. - **Deep-read the data types section** (~16%–19%): Understanding scalars, arrays, and hashes is non-negotiable for Perl. Pay special attention to negative indexing and hash semantics—these differ from many other languages. - **Study the operator precedence table carefully** (~25%–28%): Rather than memorizing every row, focus on the operators you'll use daily (`=~`, `~~`, arithmetic, comparison) and bookmark the full table for reference. - **The regex chapter rewards multiple readings** (~38%–47%): The "leftmost wins" principle and greedy/minimal matching distinctions are subtle. Work through the examples with actual strings to internalize the behavior. - **Treat this as a reference, not a cover-to-cover read**: The book's organization supports targeted lookup. Use the table of contents and index to find specific topics when you need them. ## 【Coverage Limits】 This guide synthesizes excerpts covering roughly the first half of the book (through ~47%). Later chapters on subroutines, objects, CPAN, and advanced Unicode features are not covered here. ##
Page 5
1-3. Increment operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 1-4. Logical operators . . . . ....
View in text
Excerpt 2
call these data structures rather than types. That’s okay. Scalars are the fundamental type from which more complicated structures are built. A scalar stores...
View in text
Excerpt 3
the break keyword to break out of the enclosing given block. Every when block is implicitly ended with a break. You can use the continue keyword to fall thro...
View in text
Excerpt 4
matches exist, but these start at different offsets in the string, then their lengths don’t matter—nor does it matter whether you’ve used a minimal quantifie...
View in text
Excerpt 5
of our own culture. But now that we’re starting to use the Internet for cross-cultural communication, we’re running into problems with the exclusive approach...
View in text
Excerpt 6
including the nonalphabetic variables, like $!, $?, and $_.7 In addition, when unqualified, the identifiers STDIN, STDOUT, STDERR, ARGV, ARGVOUT, ENV, INC, a...
View in text
Excerpt 7
s. You can warp those behaviors in various useful ways with tie, by associating the variable with a class that implements a new set of behav- iors. For insta...
View in text
Excerpt 8
erl will switch to that directory before running the script. The –x switch controls the disposal of leading garbage only, not trailing garbage. The script mu...
View in text
Tags
AI categories
Programming LanguageBackendTechnology
ISBN: 0596004923
Publisher: O'Reilly Media
Publish Year: 2012
Language: English
Pages: 1184
File Format: PDF
File Size: 20.2 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…