21天入门Perl系列,DAY 0

Introduction

这本书能够在21天里教你学习入门perl这门编程语言。当你读完这本书的时候,你就知道为什么Perl的快速的流行的原因:因为Perl强大的解决各种编程任务,容易学习和使用。

Who should read this book ?

没有任何编程经验的人群需要从这本书中尽可能学习任何你能够学到的相关Perl编程知识。尤其是没有C语言编程知识。如果你熟悉一门其他编程语言,那么学习Perl会比较容易。唯一的要点是你需要熟悉基本的UNIX操作系统。

Special features of this book

这本书包括了一些特殊的元素能够来帮助你理解和学习Perl的特点和概念:

语法框
DO/DON’T boxes(对错框?不知道怎么翻译)
注释
警告
贴士
语法框解释Perl的一些复杂的特点,比如控制结构。每个语法框包括了一个正式的定义和解释。

for 循环:
for (expr1; expr2; expr3) {
statement_block
}

expr1 是循环起始值,只在循环开始钱运行一次。
expr2 是终止循环的条件表达式,就像是 while 和 if 一样。如果值为0,循环结束,值不为0,循环继续。
statement_block 是当expr2的值非0时执行的陈述语句。
expr3 每一个循环执行一次,在上一次 statement_block 执行完后才执行。

不要试图去理解这些定义。

DO/DON’T boxes 展示了对特定任务中正确的和错误的使用方法。

DON’T confuse the|operator (bitwise OR) with the||operator (logical OR).

DO make sure you are using the proper bitwise operator. It’s easy to slip and assume you
want bitwise OR when you really want bitwise AND. (Trust me.
注释解释了一些特定的程序的有趣的特性
In left-justified output, the value being displayed appears at the left end of the value field. In right-justified output, the value being displayed appears at the right end of the value field.

警告是对你编程中的遇见的陷阱的警示。
You cannot use the last statement inside the do statement. The do statement, although it behaves like the other control structures, is actually implemented differently.

贴士是知道你如何写出更好的Perl程序。
It is a good idea to use all uppercase letters for your file variable names. This makes it easier to distinguish file variable names from other variable names from reserved words.

Programming Examples
每个Perl的知识点都用一个例子来解释他的使用方法。另外,每一章节都包含了很多个例子来解释;这些例子为你自己的Perl编程提供帮助。
每个例子都包含了一系列的程序,输入和输出,分析程序的运行。特殊的标记被用来指示每一个部分:类型,输入输出,分析。

IN.1中的输入输出例子,有一些特殊的格式转换。输入在 bold monspace,输出在plain monspace. $ 出现表示输入命令行运行。

#!/usr/bin/perl
# this program reads a line of input, and writes the line back out
$inputline = <STDIN>; #read a line of input
print ($inputline); #write the line out

End of day Q&A and workshop
每一天都要完成相关的Q&A,包括问题和编程测试。练习一般是做debug。答案在Appendix A.

Conventions Used in This Book

This book uses different typefaces to help you differentiate between Perl code and regular English, and also to help you identify important concepts. lActual Perl code is typeset in a special monospace font. You’ll see this font used in listings and the Input-Output examples, as well as in code snippets. In the explanations of Perl features, commands, filenames, statements, variables, and any text you see on the screen also are typeset in this font. lCommand input and anything that you are supposed to enter appears in a boldmonospace font. You’ll see this mainly in the Input-Output examples. lPlaceholders in syntax descriptions appear in an italicmonospace font. Replace the placeholder with the actual filename, parameter, or whatever element it represents. lItalics highlight technical terms when they first appear in the text and are sometimes used to emphasize important points.

What You’ll Learn in 21 Days

here’s a summary of what you’ll learn
Day 1, “Getting Started,” tells you how to get Perl, how to run Perl programs, and how to
read from your keyboard and write to your screen.
Day 2, “Basic Operators and Control Flow,” teaches you about simple arithmetic, how to assign a value to a scalar variable, and how to control execution using conditional statements.
Day 3, “Understanding Scalar Values,” teaches you about integers, floating-point numbers, and character strings. It also shows you that all three are interchangeable in Perl.
Day 4, “More Operators,” tells you all about operators and expressions in Perl and talks about operator associativity and precedence.
Day 5, “Lists and Array Variables,” introduces you to lists, which are collections of values, and to array variables, which store lists.
Day 6, “Reading from and Writing to Files,” tells you how to interact with your file system by reading from input files, writing to output files, and testing for particular file attributes.
Day 7, “Pattern Matching,” describes pattern-matching in Perl and shows how you can substitute values and translate sets of characters in text strings. By the end of Week 2, you’ll have mastered almost all the features of Perl; you’ll also have learned about many of the library functions supplied with the language. Here’s a summary of what you’ll learn:
Day 8, “More Control Structures,” discusses the control flow statements not previously covered.
Day 9, “Using Subroutines,” shows how you can break your program into smaller, more manageable, chunks.
Day 10, “Associative Arrays,” introduces one of the most powerful and useful constructs in Perl-arrays-and it shows how you can use these arrays to simulate other data structures.
Day 11, “Formatting Your Output,” shows how you can use Perl to produce tidy reports.
Day 12, “Working with the File System,” shows how you can interact with your system’s directory structure.
Day 13, “Process, String, and Mathematical Functions,” describes the library functions that interact with processes running on the system. It also describes the functions that perform trigonometric and other mathematical operations, and the functions that operate on strings.
Day 14, “Scalar-Conversion and List-Manipulation Functions,” describes the library functions that convert values from one form to another and the functions that work with lists and array variables. By the end of Week 3, you’ll know all the features and capabilities of Perl. It covers the rest of the Perl library functions and describes some of the more esoteric concepts of the language. Here’s a summary of what you’ll learn:
Day 15, “System Functions,” describes the functions that manipulate the Berkeley UNIX and UNIX System V environments.
Day 16, “Command-Line Options,” describes the options you can supply with Perl to control how your program runs.
Day 17, “System Variables,” describes the built-in variables that are included automatically as part of every Perl program.
Day 18, “References in Perl 5,” describes the pointer and reference features of Perl 5, including multi-dimensional arrays.
Day 19, “Object-Oriented Programming in Perl,” describes the object-oriented capabilities added to Perl 5. These enable you to hide information and divide your program into individual file modules.
Day 20, “Miscellaneous Features of Perl,” covers some of the more exotic or obscure features of the language.
Day 21, “The Perl Debugger,” shows you how to use the Perl debugger to discover errors quickly.

Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s