Intermediate Perl(影印版)
分類: 图书,计算机/网络,程序设计,Perl,
作者: (美)施瓦茨,(美)福格,(美)菲尼克斯著
出 版 社:
出版时间: 2008-8-1字数: 294000版次: 1页数: 256印刷时间: 2008/08/01开本: 16开印次: 1纸张: 胶版纸I S B N : 9787564112356包装: 平装编辑推荐
“这是本多么闪耀夺目的Perl书籍啊……这本书为那些渴望提高技能或者提升职业生涯的Perl程序员填补了空白。更为重要的是,看这本书有一种向大师学习的感觉。”
——Russell J.T. Dyer, UnixReview.com
内容简介
从一个Perl爱好者到一个Perl程序员。《Intermediate Perl》将教您如何把Perl作为编程语言来使用,而不仅只是作为一种脚本语言。
Perl是一种灵活多变、功能强大的编程语言,可以应用在从系统管理到网络编程再到数据库操作等很多方面。人们常说Perl让容易的事情变简单、让困难的事情变得可行。《Intermediate Perl》正是关于如何将技能从处理简单任务跃升到胜任困难任务的书籍。
本书提供对Perl中级编程优雅而仔细的介绍。由畅销的《学习Perl》作者所著,本书提供了《学习Perl》没有涵盖的内容。
主题包括:
包和命名空间
引用和作用域
操作复杂数据结构
面向对象编程
编写和使用模块
测试Perl代码
为CPAN贡献代码
参照《学习Perl》的成功编排格式,本书的每一章都短小到可以在一到两个小时内读完,并在结束时提供一系列练习题帮助您实践刚刚学到的知识。使用本书,您只需熟悉《学习Perl》的内容并有更进一步学习的决心。
对于不同的人而言Perl是一种不同的语言。对于某些人而言,它只是快速编写脚本的工具,但对于另外的人来说,它就是一种功能完整的面向对象语言。Perl被应用在各种任务当中,从对文本文件进行快速全局替换,到计算需要数星期才能完成处理的海量复杂科学数据。您的使用决定Perl的面貌。但不论您将Perl应用在什么方面,本书将帮助您让应用更加有效、高效和优雅。
《Intermediate Perl》是为了把Perl作为一种编程语言来学习,而不仅是为了写脚本而著。这本书把Perl爱好者变为Perl程序员。
目录
Foreword
Preface
1. Introduction
What Should You Know Already?
What About All Those Footnotes?
What's with the Exercises?
What If I'm a Perl Course Instructor?
2. Intermediate Foundations
List Operators
Trapping Errors with eval
Dynamic Code with eval
Exercises
3. Using Modules
The Standard Distribution
Using Modules
Functional Interfaces
Selecting What to Import
Object-Oriented Interfaces
A More Typical Object-Oriented Module: Math::Biglnt
The Comprehensive Perl Archive Network
Installing Modules from CPAN
Setting the Path at the Right Time
Exercises
4. Introduction to References
Performing the Same Task on Many Arrays
Taking a Reference to an Array
Dereferencing the Array Reference
Getting Our Braces Off
Modifying the Array
Nested Data Structures
Simplifying Nested Element References with Arrows
References to Hashes
Exercises
5. References and Scoping .
More Than One Reference to Data
What If That Was the Name?
Reference Counting and Nested Data Structures
When Reference Counting Goes Bad
Creating an Anonymous Array Directly
Creating an Anonymous Hash
Autovivification
Autovivification and Hashes
Exercises
6. Manipulating Complex Data Structures
Using the Debugger to View Complex Data
Viewing Complex Data with Data: :Dumper
YAML
Storing Complex Data with Storable
Using the map and grep Operators
Applying a Bit of Indirection
Selecting and Altering Complex Data
Exercises
7. Subroutine References
Referencing a Named Subroutine
Anonymous Subroutines
Callbacks
Closures
Returning a Subroutine from a Subroutine
Closure Variables as Inputs
Closure Variables as Static Local Variables
Exercise
8. Filehandle References
The Old Way
The Improved Way
The Even Better Way
IO::Handle
Directory Handle References
Exercises
9. Practical Reference Tricks
Review of Sorting
Sorting with Indices
Sorting Efficiently
The Schwartzian Transform
Multi-Level Sort with the Schwartzian Transform
Recursively Defined Data
Building Recursively Defined Data
Displaying Recursively Defined Data
Exercises
10. Building Larger Programs
The Cure for the Common Code
Inserting Code with eval
Using do
Using require
require and @INC
The Problem of Namespace Collisions
Packages as Namespace Separators
Scope of a Package Directive
Packages and Lexicals
Exercises
11. Introduction to Objects
If We Could Talk to the Animals...
Introducing the Method Invocation Arrow
The Extra Parameter of Method Invocation
Calling a Second Method to Simplify Things
A Few Notes About @ISA
Overriding the Methods
Starting the Search from a Different Place
The SUPER Way of Doing Things
What to Do with @_
Where We Are So Far
Exercises
12. Objects with Data
A Horse Is a Horse, of Course of Course--or Is It?
Invoking an Instance Method
Accessing the Instance Data
How to Build a Horse
Inheriting the Constructor
Making a Method Work with Either Classes or Instances
Adding Parameters to a Method
More Interesting Instances
A Horse of a Different Color
Getting Our Deposit Back
Don't Look Inside the Box
Faster Getters and Setters
Getters That Double as Setters
Restricting a Method to Class-Only or Instance-Only
Exercise
13. Object Destruction
Cleaning Up After Yourself
Nested Object Destruction
Beating a Dead Horse
Indirect Object Notation
Additional Instance Variables in Subclasses
Using Class Variables
Weakening the Argument
Exercise
14. Some Advanced Object Topics
UNIVERSAL Methods
Testing Our Objects for Good Behavior
AUTOLOAD as a Last Resort
Using AUTOLOAD for Accessors
Creating Getters and Setters More Easily
Multiple Inheritance
Exercises
15. Exporter
What use Is Doing
Importing with Exporter
@EXPORT and @EXPORT_OK
%EXPORT_TAGS
Exporting in a Primarily OO Module
Custom Import Routines
Exercises
16. Writing a Distribution
There's More Than One Way To Do It
Using h2xs
Embedded Documentation
Controlling the Distribution with Makefile.PL
Alternate Installation Locations (PREFIX=...)
Trivial make test
Trivial make install
Trivial make dist
Using the Alternate Library Location
Exercise
17. Essential Testing
More Tests Mean Better Code
A Simple Test Script
The Art of Testing
The Test Harness
Writing Tests with Test: :More
Testing Object-Oriented Features
A Testing To-Do List
Skipping Tests
More Complex Tests (Multiple Test Scripts)
Exercise
18. Advanced Testing
Testing Large Strings
Testing Files
Testing STDOUT or STDERR
Using Mock Objects
Testing POD
Coverage Testing
Writing Your Own Test: Modules
Exercises
19. Contributing to CPAN
The Comprehensive Perl Archive Network
Getting Prepared
Preparing Your Distribution
Uploading Your Distribution
Announcing the Module
Testing on Multiple Platforms
Consider Writing an Article or Giving a Talk
Exercise
Appendix: Answers to Exercises
Index