Share E-Book
Scan to open this page

Scan with your phone to open this page

AuthorRandal L. Schwartz, brian d foy, Tom Phoenix

<p>If you're just getting started with Perl, this is the book you want—whether you're a programmer, system administrator, or web hacker. Nicknamed "the Llama" by two generations of users, this best seller closely follows the popular introductory Perl course taught by the authors since 1991. This eighth edition covers recent changes to the language up to version 5.34.</p><p>Perl is suitable for almost any task on almost any platform, from short fixes to complete web applications. Learning Perl teaches you the basics and shows you how to write simple, single-file programs—roughly 90% of the Perl programs in use today. And each chapter includes exercises to help you practice what you've just learned. Other books may teach you to program in Perl, but this book will turn you into a Perl programmer.</p><p>Topics include:</p><ul><li>Perl data and variable types</li><li>Subroutines</li><li>File operations</li><li>Regular expressions</li><li>String manipulation (including Unicode)</li><li>Lists and sorting</li><li>Process management</li><li>Use of third-party modules</li></ul>

AI Reading Assistant

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

AI guide
【One-Line Pitch】 If you're new to Perl and want to move from "can read a script" to "can write your own," this is the classic, hands-on guide—ideal for programmers, sysadmins, and web tinkerers who want a practical, exercise-driven foundation in the language. 【Book Arc】 - **Opening (~0%–6%)**: Introduces Perl's philosophy, history, and setup. Covers the basics of writing and running a first program, including text editors, file permissions, and the `perldoc` system. Solves the problem of getting a working Perl environment and understanding the language's "easy things easy" mindset. - **Early (~6%–19%)**: Dives into scalar data—numbers, strings, and the core operators—along with the `if`/`while` control structures and user input. Establishes the fundamental building blocks of any Perl program, including how to handle Boolean values and the `undef` value. - **Early (~19%–34%)**: Moves to lists and arrays, covering how to create, access, and manipulate them with operators like `push`, `pop`, `shift`, and `splice`. Also explains context (scalar vs. list), a crucial Perl concept that determines how expressions behave. Solves the problem of managing collections of data efficiently. - **Middle (~34%–47%)**: Focuses on scalar variables and assignment in depth, including compound assignment operators and string concatenation. Then returns to arrays, showing how to interpolate them into strings and handle common pitfalls like email addresses. Reinforces the importance of understanding context for writing correct code. - **Middle (~47%–53%)**: Continues with more advanced array techniques, such as forcing scalar context with the `scalar` function and reading all input lines at once with `<STDIN>` in list context. Addresses edge cases and common mistakes, preparing readers for more complex data handling. - **Late (~53%–end)**: The excerpts suggest the book progresses into subroutines, file operations, regular expressions, and process management. It also covers using third-party modules, rounding out the journey from basic syntax to practical, real-world Perl programming. 【Key Takeaways】 - **Perl is a practical, text-processing language** (Early): Created by Larry Wall in the mid-1980s to handle report generation, it's designed for "easy things easy and hard things possible." This philosophy shapes its flexible syntax and "There's More Than One Way To Do It" (TMTOWTDI) approach. - **Scalars are the foundation of data** (Early): A scalar holds a single value—a number or a string. Understanding how to assign, compare, and manipulate scalars with operators like `.` (concatenation) and `+=` is the first step to writing any Perl logic. - **Control structures manage the flow** (Early): The `if` and `while` structures, combined with Perl's simple Boolean rules (where `undef`, `0`, and empty strings are false), allow you to build decision-making and looping into your programs. - **Lists and arrays handle collections** (Early): Arrays are ordered lists of scalars. Mastering operators like `push`, `pop`, `shift`, `unshift`, and `splice` lets you efficiently manage dynamic data, a task that's often more complex in other languages. - **Context is everything in Perl** (Middle): The same expression can return different values depending on whether it's in scalar or list context. For example, `@rocks` in a list context gives all elements, but `scalar @rocks` gives the count. This is a core concept that distinguishes Perl from many other languages. - **String interpolation is powerful but tricky** (Middle): Double-quoted strings automatically expand variables and arrays, which is convenient but can cause surprises, like with email addresses (`@bedrock`). Escaping with `\@` or using single quotes is the solution. - **The `undef` value is a special state** (Early): Variables that haven't been assigned a value are `undef`, which acts as false in Boolean contexts. The `defined` function lets you check for this state explicitly, which is crucial for avoiding errors when reading input or accessing array elements. 【Reading Tips】 - **Do the exercises**: Each chapter ends with practical problems, and the answers are in the appendix. These are not optional—they're the core of the "turn you into a Perl programmer" promise. Type in the code and run it. - **Skim the history and preface**: The early sections on Perl's origins and the "Llama" course are interesting but not essential for coding. Feel free to skim them and jump to the technical chapters. - **Deep-read the context chapters**: The sections on scalar vs. list context and array interpolation are where many beginners get confused. Read these slowly and experiment with the examples to build a solid mental model. - **Use `perldoc`**: The book emphasizes this built-in documentation tool. When you encounter a function you don't know, like `splice` or `chomp`, look it up with `perldoc -f function_name` to get the official details. - **Don't worry about "hard things" yet**: The book's title is aspirational. This guide focuses on the basics for single-file programs. Advanced topics like `fork` and signals are covered later; for now, focus on getting the fundamentals right. 【Coverage Limits】 This guide synthesizes the provided excerpts, which cover the book's introduction, scalar data, lists/arrays, and some control flow. It does not detail the later chapters on subroutines, regular expressions, file handling, or process management, which are mentioned in the table of contents but not excerpted in depth.
Excerpt 1
20 Nondecimal Integer Literals 20 Floating-Point Literals 21 Numeric Operators 22 Strings 23 Single-Quoted String Literals 23 Double-Quoted String Literals 2...
View in text
Excerpt 2
nning array of Fortune 1000 clients that have purchased our classes in the past and will continue to do so into the future. As always, a special thanks to Ly...
View in text
Excerpt 3
h between the quote marks stands for itself inside a string. If you want a literal single quote or backslash inside your string, you need to escape it with a...
View in text
Excerpt 4
et a warning: Possible unintended interpolation of @bedrock To get around this problem, you either escape the @ in a double-quoted string or use a single-quo...
View in text
Excerpt 5
When you run this, you can see the default values at work: defaults: 0 1 2 3 4 5 6 7 default_end: 17 16 15 14 13 12 11 10 9 8 7 Sometimes you want optional a...
View in text
Excerpt 6
offers many shortcuts that can help the programmer. Here’s a handy one: you may omit the quote marks on some hash keys when you use the fat comma, which auto...
View in text
Excerpt 7
ces here for the delimiters, allowing programmer-style edi‐ tors to easily bounce from the beginning to the end of the regular expression. Choosing a Charact...
View in text
Excerpt 8
sn’t run into the next part of the pattern (see Table 9-1). Table 9-1.
View in text
Tags
AI categories
Programming LanguagePerlEducation
perl
ISBN: 1492094951
Publisher: O'Reilly Media
Publish Year: 2021
Language: English
Pages: 398
File Format: PDF
File Size: 5.5 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…