Intermediate perl 总结提高

本文档总结了Perl编程的中级知识,包括重要的语法特性、模块使用和实战技巧,旨在提升Perl编程技能。
摘要由CSDN通过智能技术生成

第一章

简介

第二章

File::Spec 模块还提供了许多其它的方法来用可移植的方式处理路径。你可以通过perlport 文档了解更多有关移植方面的专题。
grep 操作符取一个列表和一个"测试表达式". 它一个一个地从列表中把元素取出来放到$_ 变量中, 并在标量环境中, 用"测试表达式"来检验这个值.如果检验出来是个"真"值, grep 会把$_ 变量送到输出列表中。
grep 中的测试表达式在map 中变成了映射表达式.map 操作符在列表环
境中为表达式求值(而不是像grep 那样在标量环境下求值).
Math::BigInt , 它用来处理超出Perl内置精度的整数值.[ *] [*]


一个Perl 标量变量保存一个单个值。一个数组保存一个或多个标量的次序列
表。一个散列保存一个标量作为键值, 另一个标量作为值。尽管一个标量可以
是任意字串, 可以被复杂数据结构用来编入一个数组或一个散列, 但是三种数据类型中没有一个适合用来做复杂数据关系。这就是引用的工作。我们由一个例
子来探查一下引用的重要性。
标量合适的操作对于引用都一样合适.它可以是数组或散列中的一个元素, 或简
单就是一个标量变量。


第三章
1 为了保证平台兼容性,多使用Cwd取当前目录。
use Cwd;
my $dir = getcwd;
或者
my $dir = cwd;
my $dir = fastgetcwd;
它们都返回程序运行的当前路径.
use Cwd 'abs_path';
my $abs_path = abs_path($file);
或者$abs_path = realpath($file);
或者$abs_path= fast_abs_path($file);
2 glob()又叫做文件名聚焦操作符,是一个强大的文本处理器。
定义和用法
返回相匹配的文件EXPR的列表,因为他们将扩大标准的Bourne shell。如果expr不指定路径,则使用当前目录。如果EXPR被忽略,那么使用$_的值。
从Perl5.6扩展内部完成,而不是使用外部脚本。 扩展如csh(及任何衍生工具,包括tcsh和bash的)风格的扩展,该转换,如下所示:
开始带一个单一的文件EXPR被忽略,除非明确地匹配。
* 字符匹配零个或多个字符的任何类型的。
? 任何类型的字符匹配一个字符。
[..] 结构相匹配的字符,包括范围,按正则表达式。
〜 字符
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Over a decade ago (nearly eternity in Internet Time), Randal Schwartz wrote the first edition of Learning Perl. In the intervening years, Perl itself has grown substantially from a "cool" scripting language used primarily by Unix system administrators to a robust object-oriented programming (OOP) language that runs on practically every computing platform known to mankind. Throughout its four editions, Learning Perl remained the same size (about 300 pages) and continued to cover much of the same material to remain compact and accessible to the beginning programmer. But there is much more to learn about Perl now than when that first book was written. Randal called the first edition of this book Learning Perl Objects, References, and Modules, and now it's Intermediate Perl, but we like to think of it as just Learning More Perl. [*] This is the book that picks up where Learning Perl leaves off. We show you how to use Perl to write larger programs. [*] Don't ask why it isn't called that. We must have had 300 emails on the subject. Okay, ask, since we know you're going to anyway. You never really stop learning Perl, so Learning More Perl doesn't really tell you much about the book. Our editor chose the name, which tells you what to expect. As in Learning Perl, we designed each chapter to be small enough to read in just an hour or so. Each chapter ends with a series of exercises to help you practice what you've just learned, and the answers are in the appendix for your reference. And like Learning Perl, we've developed the material in this book for a teaching environment and used it in that setting, including for our own use at Stonehenge Consulting Services, as we conduct on-site and open-enrollment trainings. You don't have to be a Unix guru, or even a Unix user, to benefit from this book. Unless otherwise noted, everything in this book applies equally well to Windows ActivePerl from ActiveState and all other modern implementations of Perl. To use this book, you just need to be familiar with the material in Learning Perl and have the ambition to go further. Structure of This Book You should read this book from front to back, stopping to do the exercises. Each chapter builds on preceding chapters, and we'll assume that you know the material from those chapters as we discuss new topics. Chapter 1, Introduction - 2 - Intermediate Perl An introduction to the material. Chapter 2, Intermediate Foundations Pick up some intermediate Perl skills you'll need for the rest of the book. Chapter 3, Using Modules Use Perl's core modules, as well as modules from other people. We're going to show you how to create your own modules later in the book, but until we do, you can still use modules you already have. Chapter 4, Introduction to References Introduce a level of redirection to allow the same code to operate on different sets of data. Chapter 5, References and Scoping Learn how Perl manages to keep track of pointers to data, and an introduction to anonymous data structures and autovivification. Chapter 6, Manipulating Complex Data Structures Create, access, and print arbitrarily deep and nested data structures, including arrays of arrays and hashes of hashes. Chapter 7, Subroutine References Capture behavior as an anonymous subroutine that you create dynamically and execute later. Chapter 8, Filehandle References Store filehandles in scalar variables that you can easily pass around your program or store in data structures. Chapter 9, Practical Reference Tricks Sorting complex operations, the Schwartzian Transform, and working with recursively defined data. Chapter 10, Building Larger Programs Build larger programs by separating code into separate files and namespaces. Chapter 11, Introduction to Objects - 3 - Intermediate Perl Work with classes, method calls, inheritance, and overriding. Chapter 12, Objects with Data Add per-instance data, including constructors, getters, and setters. Chapter 13, Object Destruction Add behavior to an object that is going away, including object persistence. Chapter 14, Some Advanced Object Topics Use multiple inheritance, automatic methods, and references to filehandles. Chapter 15, Exporter How use works, how we can decide what to export, and how we can create our own import routines. Chapter 16, Writing a Distribution Package a module for sharing, including portable installation instructions. Chapter 17, Essential Testing Test your code to ensure it does what you want it to do. Chapter 18, Advanced Testing Test complex aspects of code and meta-code things such as documentation and test coverage. Chapter 19, Contributing to CPAN Share your work with the world by uploading it to CPAN. Appendix, Answers to Exercises Where to go to get answers. Conventions Used in This Book The following typographic conventions are used in this book: Constant width - 4 - Intermediate Perl Used for function names, module names, filenames, environment variables, code snippets, and other literal text Italics Used for emphasis and for new terms where they are defined
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值