Tài liệu Teach Yourself Perl 5 in 21 days doc

1.1K 452 0
Tài liệu Teach Yourself Perl 5 in 21 days doc

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Teach Yourself Perl 5 in 21 days David Till Table of Contents: Introduction ● Who Should Read This Book? ● Special Features of This Book ● Programming Examples ● End-of-Day Q& A and Workshop ● Conventions Used in This Book ● What You'll Learn in 21 Days Week 1 Week at a Glance ● Where You're Going Day 1 Getting Started ● What Is Perl? ● How Do I Find Perl? ❍ Where Do I Get Perl? ❍ Other Places to Get Perl ● A Sample Perl Program ● Running a Perl Program ❍ If Something Goes Wrong ● The First Line of Your Perl Program: How Comments Work ❍ Comments ● Line 2: Statements, Tokens, and <STDIN> ❍ Statements and Tokens ❍ Tokens and White Space ❍ What the Tokens Do: Reading from Standard Input ● Line 3: Writing to Standard Output ❍ Function Invocations and Arguments ● Error Messages ● Interpretive Languages Versus Compiled Languages ● Summary ● Q&A ● Workshop ❍ Quiz ❍ Exercises Day 2 Basic Operators and Control Flow ● Storing in Scalar Variables Assignment ❍ The Definition of a Scalar Variable ❍ Scalar Variable Syntax ❍ Assigning a Value to a Scalar Variable ● Performing Arithmetic ❍ Example of Miles-to-Kilometers Conversion ❍ The chop Library Function ● Expressions ❍ Assignments and Expressions ● Other Perl Operators ● Introduction to Conditional Statements ● The if Statement ❍ The Conditional Expression ❍ The Statement Block ❍ Testing for Equality Using == ❍ Other Comparison Operators ● Two-Way Branching Using if and else ● Multi-Way Branching Using elsif ● Writing Loops Using the while Statement ● Nesting Conditional Statements ● Looping Using the until Statement ● Summary ● Q&A ● Workshop ❍ Quiz ❍ Exercises Day 3 Understanding Scalar Values ● What Is a Scalar Value? ● Integer Scalar Values ❍ Integer Scalar Value Limitations ● Floating-Point Scalar Values ❍ Floating-Point Arithmetic and Round-Off Error ● Using Octal and Hexadecimal Notation ❍ Decimal Notation ❍ Octal Notation ❍ Hexadecimal Notation ❍ Why Bother? ● Character Strings ❍ Using Double-Quoted Strings ❍ Escape Sequences ❍ Single-Quoted Strings ● Interchangeability of Strings and Numeric Values ❍ Initial Values of Scalar Variables ● Summary ● Q&A ● Workshop ❍ Quiz ❍ Exercises Day 4 More Operators ● Using the Arithmetic Operators ❍ Exponentiation ❍ The Remainder Operator ❍ Unary Negation ● Using Comparison Operators ❍ Integer-Comparison Operators ❍ String-Comparison Operators ❍ String Comparison Versus Integer Comparison ❍ Comparison and Floating-Point Numbers ● Using Logical Operators ❍ Evaluation Within Logical Operators ❍ Logical Operators as Subexpressions ● Using Bit-Manipulation Operators ❍ What Bits Are and How They Are Used ❍ The Bit-Manipulation Operators ● Using the Assignment Operators ❍ Assignment Operators as Subexpressions ● Using Autoincrement and Autodecrement ❍ The Autoincrement Operator Pre-Increment ❍ The Autoincrement Operator Post-Increment ❍ The Autodecrement Operator ❍ Using Autoincrement With Strings ● The String Concatenation and Repetition Operators ❍ The String-Concatenation Operator ❍ The String-Repetition Operator ❍ Concatenation and Assignment ● Other Perl Operators ❍ The Comma Operator ❍ The Conditional Operator ● The Order of Operations ❍ Precedence ❍ Associativity ❍ Forcing Precedence Using Parentheses ● Summary ● Q&A ● Workshop ❍ Quiz ❍ Exercises Day 5 Lists and Array Variables ● Introducing Lists ● Scalar Variables and Lists ❍ Lists and String Substitution ● Storing Lists in Array Variables ● Accessing an Element of an Array Variable ❍ More Details on Array Element Names ● Using Lists and Arrays in Perl Programs ❍ Using Brackets and Substituting for Variables ● Using List Ranges ❍ Expressions and List Ranges ● More on Assignment and Array Variables ❍ Copying from One Array Variable to Another ❍ Using Array Variables in Lists ❍ Substituting for Array Variables in Strings ❍ Assigning to Scalar Variables from Array Variables ● Retrieving the Length of a List ● Using Array Slices ❍ Using List Ranges in Array-Slice Subscripts ❍ Using Variables in Array-Slice Subscripts ❍ Assigning to Array Slices ❍ Overlapping Array Slices ❍ Using the Array-Slice Notation as a Shorthand ● Reading an Array from the Standard Input File ● Array Library Functions ❍ Sorting a List or Array Variable ❍ Reversing a List or Array Variable ❍ Using chop on Array Variables ❍ Creating a Single String from a List ❍ Splitting a String into a List ❍ Other List-Manipulation Functions ● Summary ● Q&A ● Workshop ❍ Quiz ❍ Exercises Day 6 Reading from and Writing to Files ● Opening a File ❍ The File Variable ❍ The Filename ❍ The File Mode ❍ Checking Whether the Open Succeeded ● Reading from a File ❍ File Variables and the Standard Input File ❍ Terminating a Program Using die ❍ Reading into Array Variables ● Writing to a File ❍ The Standard Output File Variable ❍ Merging Two Files into One ● Redirecting Standard Input and Standard Output ● The Standard Error File ● Closing a File ● Determining the Status of a File ❍ File-Test Operator Syntax ❍ Available File-Test Operators ❍ More on the -e Operator ❍ Testing for Read Permission-the -r Operator ❍ Checking for Other Permissions ❍ Checking for Empty Files ❍ Using File-Test Operators with File Variables ● Reading from a Sequence of Files ❍ Reading into an Array Variable ● Using Command-Line Arguments as Values ❍ ARGV and the <> Operator ● Opening Pipes ● Summary ● Q&A ● Workshop ❍ Quiz ❍ Exercises Day 7 Pattern Matching ● Introduction ● The Match Operators ❍ Match-Operator Precedence ● Special Characters in Patterns ❍ The + Character ❍ The [] Special Characters ❍ The * and ? Special Characters ❍ Escape Sequences for Special Characters ❍ Matching Any Letter or Number ❍ Anchoring Patterns ❍ Variable Substitution in Patterns ❍ Excluding Alternatives ❍ Character-Range Escape Sequences ❍ Matching Any Character ❍ Matching a Specified Number of Occurrences ❍ Specifying Choices ❍ Reusing Portions of Patterns ❍ Pattern-Sequence Scalar Variables ❍ Special-Character Precedence ❍ Specifying a Different Pattern Delimiter ● Pattern-Matching Options ❍ Matching All Possible Patterns ❍ Ignoring Case ❍ Treating the String as Multiple Lines ❍ Evaluating a Pattern Only Once ❍ Treating the String as a Single Line ❍ Using White Space in Patterns ● The Substitution Operator ❍ Using Pattern-Sequence Variables in Substitutions ❍ Options for the Substitution Operator ❍ Evaluating a Pattern Only Once ❍ Treating the String as Single or Multiple Lines ❍ Using White Space in Patterns ❍ Specifying a Different Delimiter ● The Translation Operator ❍ Options for the Translation Operator ● Extended Pattern-Matching ❍ Parenthesizing Without Saving in Memory ❍ Embedding Pattern Options ❍ Positive and Negative Look-Ahead ❍ Pattern Comments ● Summary ● Q&A ● Workshop ❍ Quiz ❍ Exercises Week 1 Week 1 in Review Week 2 Week 2 at a Glance ● Where You're Going Day 8 More Control Structures ● Using Single-Line Conditional Statements ❍ Problems with Single-Line Conditional Statements ● Looping Using the for Statement ❍ Using the Comma Operator in a for Statement ● Looping Through a List: The foreach Statement ❍ The foreach Local Variable ❍ Changing the Value of the Local Variable ❍ Using Returned Lists in the foreach Statement ● The do Statement ● Exiting a Loop Using the last Statement ● Using next to Start the Next Iteration of a Loop ● The redo Statement ● Using Labeled Blocks for Multilevel Jumps ❍ Using next and redo with Labels ● The continue Block ● The goto Statement ● Summary ● Q&A ● Workshop ❍ Quiz ❍ Exercises Day 9 Using Subroutines ● What Is a Subroutine? ● Defining and Invoking a Subroutine ❍ Forward References to Subroutines ● Returning a Value from a Subroutine ❍ Return Values and Conditional Expressions ● The return Statement ● Using Local Variables in Subroutines ❍ Initializing Local Variables ● Passing Values to a Subroutine ❍ Passing a List to a Subroutine ● Calling Subroutines from Other Subroutines ● Recursive Subroutines ● Passing Arrays by Name Using Aliases ● Using the do Statement with Subroutines ● Specifying the Sort Order ● Predefined Subroutines ❍ Creating Startup Code Using BEGIN ❍ Creating Termination Code Using END ❍ Handling Non-Existent Subroutines Using AUTOLOAD ● Summary ● Q&A ● Workshop ❍ Quiz ❍ Exercises Day 10 Associative Arrays ● Limitations of Array Variables ● Definition ● Referring to Associative Array Elements ● Adding Elements to an Associative Array ● Creating Associative Arrays ● Copying Associative Arrays from Array Variables ● Adding and Deleting Array Elements ● Listing Array Indexes and Values ● Looping Using an Associative Array ● Creating Data Structures Using Associative Arrays ❍ Linked Lists ❍ Structures ❍ Trees ❍ Databases ❍ Example: A Calculator Program ● Summary ● Q&A ● Workshop ❍ Quiz ❍ Exercises Day 11 Formatting Your Output ● Defining a Print Format ● Displaying a Print Format ● Displaying Values in a Print Format ❍ Creating a General-Purpose Print Format ❍ Choosing a Value-Field Format ❍ Printing Value-Field Characters ❍ Using the Multiline Field Format ● Writing to Other Output Files ❍ Saving the Default File Variable ● Specifying a Page Header ❍ Changing the Header Print Format ● Setting the Page Length ❍ Using print with Pagination ● Formatting Long Character Strings ❍ Eliminating Blank Lines When Formatting ❍ Supplying an Indefinite Number of Lines ● Formatting Output Using printf ● Summary ● Q&A ● Workshop ❍ Quiz ❍ Exercises Day 12 Working with the File System ● File Input and Output Functions ❍ Basic Input and Output Functions ❍ Skipping and Rereading Data ❍ System Read and Write Functions ❍ Reading Characters Using getc ❍ Reading a Binary File Using binmode ● Directory-Manipulation Functions ❍ The mkdir Function ❍ The chdir Function ❍ The opendir Function ❍ The closedir Function ❍ The readdir Function ❍ The telldir and seekdir Functions ❍ The rewinddir Function ❍ The rmdir Function ● File-Attribute Functions ❍ File-Relocation Functions ❍ Link and Symbolic Link Functions ❍ File-Permission Functions ❍ Miscellaneous Attribute Functions ● Using DBM Files ❍ The dbmopen Function ❍ The dbmclose Function ● Summary ● Q&A ● Workshop ❍ Quiz ❍ Exercises Day 13 Process, String, and Mathematical Functions ● Process- and Program-Manipulation Functions ❍ Starting a Process ❍ Terminating a Program or Process ❍ Execution Control Functions ❍ Miscellaneous Control Functions ● Mathematical Functions [...]... 2: # this program reads a line of input, and writes the line 3: # back out 4: $inputline = ; # read a line of input 5: print( $inputline ); # write the line out $ programIN_1 This is a line of input This is a line of input $ Line 1 is the header comment Lines 2 and 3 are comments, not executable lines of code Line 4 reads a line of input Line 5 writes the line of input on your screen End-of-Day... Command-Line Options q q q q q q q q q q q q q q q q Specifying Options r Specifying Options on the Command Line r Specifying an Option in the Program The -v Option: Printing the Perl Version Number The -c Option: Checking Your Syntax The -w Option: Printing Warnings r Checking for Possible Typos r Checking for Redefined Subroutines r Checking for Incorrect Comparison Operators The -e Option: Executing a Single-Line... 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 objectoriented capabilities added to Perl 5 These enable you to hide information and divide your program into individual file... Do: Reading from Standard Input Line 3: Writing to Standard Output r Function Invocations and Arguments Error Messages Interpretive Languages Versus Compiled Languages Summary Q&A Workshop r Quiz r Exercises Welcome to Teach Yourself Perl 5 in 21 Days Today you'll learn about the following: q q q q q q What Perl is and why Perl is useful How to get Perl if you do not already have it How to run Perl programs... permission 250 250 -Please note that all files ending in '.gz' are compressed with 250 -'gzip', not with the unix 'compress' program Get the file README 250 - and read it for more information 250 250 -Please read the file README 250 - it was last modified on Thu Feb 1 15: 00 :50 1996 - 32 days ago 250 -Please read the file README-about-.diff-files 250 - it was last modified on Fri Feb 2 12 :57 :14 1996 - 31 days ago 250 -Please... README-about-.gz-files 250 - it was last modified on Wed Jun 14 16 :59 :43 19 95 - 264 days ago 250 CWD command successful ftp> binary 200 Type set to I ftp> get perl- 5. 001.tar.gz 200 PORT command successful 150 Opening ASCII mode data connection for perl- 5. 001.tar.gz (11307 65 bytes) 226 Transfer complete 11307 65 bytes received in 9 454 seconds (1.20 Kbytes/s) ftp> quit 221 Goodbye $ The commands entered in this session... through his company, MPS Inc., in Houston, Texas He is an alumnus of the University of Texas at Austin You can reach Kamran through Sams Publishing or via e-mail at khusain@neosoft.com or mpsi@aol.com Introduction This book is designed to teach you the Perl programming language in just 21 days When you finish reading this book, you will have learned why Perl is growing rapidly in popularity: It is powerful... require Function r The require Function and Subroutine Libraries r Using require to Specify a Perl Version The $#array Variables r Controlling Array Length Using $#array Alternative String Delimiters r Defining Strings Using . ● Predefined Subroutines ❍ Creating Startup Code Using BEGIN ❍ Creating Termination Code Using END ❍ Handling Non-Existent Subroutines Using AUTOLOAD. Formatting Your Output ● Defining a Print Format ● Displaying a Print Format ● Displaying Values in a Print Format ❍ Creating a General-Purpose Print Format

Ngày đăng: 17/01/2014, 08:20

Từ khóa liên quan

Mục lục

  • Perl Book

    • Table of Contents

    • Week 1 -- At a Glance

    • Day 1 -- Getting Started

    • Day 2 -- Basic Operators and Control Flow

    • Day 3 -- Understanding Scalar Values

    • Day 4 -- More Operators

    • Day 5 -- Lists and Array Variables

    • Day 6 -- Reading from and Writing to Files

    • Day 7 -- Pattern Matching

    • Week 1 -- In Review

    • Week 2 -- At a Glance

    • Day 8 -- More Control Structures

    • Day 9 -- Using Subroutines

    • Day 10 -- Associative Arrays

    • Day 11 -- Formatting Your Output

    • Day 12 -- Working with the File System

    • Day 13 -- Process, String, and Mathematical Functions

    • Day 14 -- Scalar-Conversion and List-Manipulation Functions

    • Week 2 -- In Review

    • Week 3 -- At a Glance

Tài liệu cùng người dùng

Tài liệu liên quan