21天入门Perl系列,DAY 0



Who should read this book ?


Special features of this book


DO/DON’T boxes(对错框?不知道怎么翻译)

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

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.

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

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

# 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.



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

WordPress.com 徽标

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

Google+ photo

You are commenting using your Google+ 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 /  更改 )


Connecting to %s