Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: 5th Edition Learning Perl [Learning Perl, 5th Edition]

《Perl语言入门(第5版)》也就是大家所称道的“小骆驼书”,是Perl程序设计人员最为仰赖的启蒙读物之一。自1993年以来,这本《Perl语言入门(第5版)》就成为热卖的Perl语言教学材料,而此次新版又涵盖了Perl 5.10的最新变化。《Perl语言入门(第5版)》的诸位作者自1991年起就开始在Stonehenge Consulting从事Perl教学工作,多年的课堂教学实践和积累下来的点滴经验,形成了《Perl语言入门(第5版)》特有的教学节奏,以及务实的知识点取舍。随文而至的习题,可以让你及时巩固各种概念,强化理解和吸收。《Perl语言入门(第5版)》容涵盖: ·Perl的变量类型 ·子程序 ·文件的操作 ·正则表达式 ·字符串的操作 ·列表与排序 ·进程的管理 ·智能匹配 ·第三方模块的使用 有些人只是想要完成任务,Perl语言为此而生。Perl的最初目标只是为了协助Unix系统管理员完成日常繁琐的文本数据处理工作。时至今日,Perl已发展成为一套功能齐备的程序语言,几乎可以在任何操作系统上完成各种任务——从简单的命令行工具到Web应用开发,及至生物信息学、金融数据分析等等不一而足。其他书籍可能会着重于教会你使用Perl语言来编程,可《Perl语言入门(第5版)》不同,我们是想要你成为一名真正的Perl程序员。

AI Reading Assistant

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

AI guide
【One-Line Pitch】 This is the classic "Llama Book" for anyone who wants to become a real Perl programmer, not just a script dabbler. It's a hands-on, exercise-driven tutorial that takes you from zero to comfortable with Perl 5.10, covering everything from basic variables to regular expressions and beyond. 【Book Arc】 - **Opening (~0%–13%)**: Introduces Perl's philosophy and practical setup. It explains what Perl is, how to get it, and the basics of writing and running your first scripts, including the shebang line and the concept that Perl programs don't require variable declarations. - **Early (~13%–25%)**: Dives into the core data types. This section covers scalars, arrays, and the crucial concept of context (scalar vs. list). It also introduces subroutines, teaching you how to define them, pass arguments, and use private variables with `my`. - **Early (~25%–38%)**: Continues with more advanced control flow and I/O. It covers standard input, the diamond operator for file processing, and the `say` function. This stage also introduces hashes, explaining how to create, access, and use them for practical tasks like tracking data. - **Middle (~38%–54%)**: Focuses heavily on regular expressions, a core Perl strength. It covers metacharacters, quantifiers, character classes, anchors, and grouping. It also introduces pattern matching, substitutions, and the `split` operator, along with other control structures like `unless` and loop controls. - **Late (~54%–100%)**: Covers more advanced topics and practicalities. This includes the logical-or and "defined-or" operators for providing defaults, and a significant section on using and installing third-party modules from CPAN, which is essential for real-world Perl work. 【Key Takeaways】 - **Perl is a language for getting things done** (Opening): It was designed for practical text processing tasks, and this book focuses on that pragmatic approach, aiming to make you a proficient programmer rather than just teaching syntax. - **Context is a fundamental concept** (Early): An expression's meaning changes based on whether Perl expects a scalar or a list. For example, an array in a list context yields its elements, but in a scalar context, it returns its element count. Understanding this is key to reading and writing Perl. - **Arrays are best manipulated with functions, not indices** (Early): Using `pop`, `push`, `shift`, and `unshift` is often faster and less error-prone than manual index management. The book humorously notes that using index-heavy C-style algorithms in Perl is like using a Stradivarius to hammer nails. - **`my` creates private variables, and `use strict` is your friend** (Early): By default, all variables are global. Using `my` to create lexical variables scoped to a block is crucial for writing maintainable code. The book strongly recommends using `use strict` for any program longer than a screen. - **Regular expressions are a powerful, built-in feature** (Middle): The book covers everything from simple metacharacters like `.` and `*` to anchors, character classes, and quantifiers. It emphasizes that a backslash escapes a metacharacter's special meaning, and introduces Perl 5.10 features like named captures to manage complex patterns. - **Non-greedy matching is essential for many substitutions** (Middle): When replacing HTML tags or similar patterns, a greedy `.*` can match too much. The book shows how to use non-greedy quantifiers like `*?` to match the smallest possible string, which is a common real-world necessity. - **The "defined-or" operator `//` provides safe defaults** (Late): Unlike `||`, which treats any false value (like `0` or an empty string) as needing a default, `//` only triggers on `undef`. This prevents subtle bugs when a legitimate value is false. - **CPAN is the go-to resource for modules** (Late): The book explains how to install and use third-party modules, which is vital for extending Perl's capabilities beyond its core. It mentions tools like the `cpan` command and the Perl Package Manager (PPM) for different systems. 【Reading Tips】 - **Do the exercises**: The book is designed for practice. The bracketed numbers in exercises estimate completion time, and working through them is essential to solidify concepts. If you're a teacher, the exercises are designed to fit within a class period. - **Deep-read the chapters on subroutines and regular expressions**: These are the most conceptually dense and important parts. Pay close attention to the examples and footnotes, which often contain crucial clarifications and best practices. - **Skim the setup and installation sections if you're already comfortable**: The early chapters on getting Perl and understanding the shebang line are useful but can be skimmed if you're not a complete beginner. - **Use the "pattern testing program"**: The book provides a simple script to test your regular expressions. Use it to experiment and understand what your patterns actually match, as this is a common area for mistakes. - **Don't get bogged down by the humor and asides**: The authors have a playful style with many footnotes. While entertaining, you can skim these to focus on the core technical content. 【Coverage Limits】 This guide is based on a sample of excerpts and does not cover the book's later sections in detail, including advanced topics like process management, references, and the `given-when` statement. The excerpts also do not include the final chapters on sorting and more complex data structures.
Page 14
知 道要怎么让计算机帮我们做这件事)。 之前提到过,我们还有⼀本辅助⽤书,《Learning Perl Student Workbook》,其中为毎 个章节都额外增加了若⼲习题。如果你已经有第 四版的这本⼯具书的话,请注怠调整⼀ 下章节的顺序,这次我们新增 了⼀章,并作了些次序上的调整。 “Perl”这个词是什么...
View in text
Excerpt 2
组元素的个数少1, 因为还有⼀个编号为0的元素: $end = $#rocks; # 99,也就是最后⼀个元素的索引值 $number_of_rocks = $end + 1; #正确,但后⾯会看到更好的做法 $rocks[ $#rocks ] = 'hard rock1; # 最后⼀块⽯头 最后⼀个例⼦⾥,把$...
View in text
Excerpt 3
0; print 11 Hello! \n"; print "Hello!", "\n"; say "Hello!"; 如果你想输出某个变量的值,并在它的末尾带上换⾏,其实不必额 外构造⼀个字符串, 也不必⽤print函数打印列表。直接say这个变量就 可以了。在你想输出某些内容 并换⾏的时候,这个函数⾮常好⽤:...
View in text
Excerpt 4
UR_PATTERN_GOES_HERE指定的模式进 当有⽤【注6】。只要你能将分隔符 写成模式(通常是很简单的正则表 达式),就可以使⽤split提取数据。它的⽤法如下: ?fields = split /separator/, $string; ? split操作符【注7】⽤拆分模式串“扫过”指定的字符串,并...
View in text
Excerpt 5
⼀样。即使它具有多个不同的⽂件 名(使⽤硬链接创建),设 备编号和inode编号的组合依然是独⼀⽆⼆ 的。 $mode ⽂件的权限位集合,还包含其他信息位。如果你曾⽤Unix命令k々 查看过详细 (冗⻓)的⽂件列表,你会看到其中每⼀⾏都是由类似-rwxr- xr-x这样的字符 串开始的。⻓度共9个字符的连字符和字...
View in text
Excerpt 6
因为我们是按从宽泛到特 殊的顺序来测试的。 如果传来的参数匹配/fred/i,Perl就不会测试其余 的when条件了。同样的道理, 我们不能⼀开始就测试是否包含Fred,因 为这样就总没有机会做后⾯的测试,执⾏到 第⼀个when语句块后,Perl 就会跳出该控制结构。 如果在when语句块的末尾使⽤contin...
View in text
Excerpt 7
把foreach循环⾥的注释去掉就⾏了。 你也许会怀疑:“为什么要先chdir呢? readdir类型的函数对当前⽬ 录并不 敏感,它其实可以作⽤在任何⽬录上”。最主要的动机是想让⽤ 户只按⼀个键,就 可以转移到其home⽬录。但是,这个程序也可以作 为“通⽤⽂件管理器”的雏 形。也许接下来我们可以设计⼀个功能,...
View in text
Excerpt 8
要系统⽀持,通常都能以动态加栽的⽅式进⾏⼆进制扩 展。如果系统不⽀持,也可以 对扩展模块进⾏静态编译,也就是说Perl 在编译时即包含了该扩展模块,可以直接使 ⽤. 注23: 没准⼉⽤这个语⾔来写字处理器是很合适的.没错我们喜爱 Perl,但是并没有发毒誓不 再⽤别的语⾔.如果语⾔X是最佳选择的话,就 该使⽤它....
View in text
Tags
AI categories
Programming LanguageBackendCode
ISBN: 0596520107
Publish Year: 2012
Language: Chinese
File Format: PDF
File Size: 3.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…