teach yourself perl 5 in 21 days

1K 389 0
teach yourself perl 5 in 21 days

Đ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❍ ● Ebook banner rotater for Web Programming and Administration http://docs.rinet.ru:8080/P7/ (1 of 30) [2/17/2007 5:58:58 AM] 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❍ ● Ebook banner rotater for Web Programming and Administration http://docs.rinet.ru:8080/P7/ (2 of 30) [2/17/2007 5:58:58 AM] 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● Ebook banner rotater for Web Programming and Administration http://docs.rinet.ru:8080/P7/ (3 of 30) [2/17/2007 5:58:58 AM] 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● Ebook banner rotater for Web Programming and Administration http://docs.rinet.ru:8080/P7/ (4 of 30) [2/17/2007 5:58:58 AM] 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❍ ● Ebook banner rotater for Web Programming and Administration http://docs.rinet.ru:8080/P7/ (5 of 30) [2/17/2007 5:58:58 AM] 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❍ ● Ebook banner rotater for Web Programming and Administration http://docs.rinet.ru:8080/P7/ (6 of 30) [2/17/2007 5:58:58 AM] 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❍ ● Ebook banner rotater for Web Programming and Administration http://docs.rinet.ru:8080/P7/ (7 of 30) [2/17/2007 5:58:58 AM] 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❍ ● Ebook banner rotater for Web Programming and Administration http://docs.rinet.ru:8080/P7/ (8 of 30) [2/17/2007 5:58:58 AM] 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● Ebook banner rotater for Web Programming and Administration http://docs.rinet.ru:8080/P7/ (9 of 30) [2/17/2007 5:58:59 AM] 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● Ebook banner rotater for Web Programming and Administration http://docs.rinet.ru:8080/P7/ (10 of 30) [2/17/2007 5:58:59 AM] [...]... command line Listing IN. 1 A simple Perl program with comments 1: #!/usr/local/bin /perl 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... http://docs.rinet.ru:8080/P7/ ( 15 of 30) [2/17/2007 5: 58 :59 AM] Ebook banner rotater for Web Programming and Administration q Workshop r Quiz r Exercises Day 16 Command-Line Options q Specifying Options r Specifying Options on the Command Line r Specifying an Option in the Program q The -v Option: Printing the Perl Version Number q The -c Option: Checking Your Syntax q The -w Option: Printing Warnings r Checking... Programming and Administration qualifications Kamran offers consulting services and training classes 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... Referring to One Package from Another r Specifying No Current Package r Packages and Subroutines r Defining Private Data Using Packages r Packages and System Variables r Accessing Symbol Tables http://docs.rinet.ru:8080/P7/ (20 of 30) [2/17/2007 5: 58 :59 AM] Ebook banner rotater for Web Programming and Administration q Modules r Creating a Module r Importing Modules Into Your Program r Using Predefined... Day 1 Getting Started 250 - it was last modified on Fri Feb 2 12 :57 :14 1996 - 31 days ago 250 -Please read the file 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... 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 http://docs.rinet.ru:8080/P7/ch1.htm (3 of 16) [2/17/2007 5: 59:11 AM]... References q For More Information q Summary q Q&A q Workshop r q Quiz Exercises Day 19 Object-Oriented Programming in Perl q An Introduction to Modules r The Three Important Rules q Classes in Perl q Creating a Class q Blessing a Constructor r Instance Variables q Methods q Exporting Methods q Invoking Methods q Overrides q Destructors http://docs.rinet.ru:8080/P7/ (19 of 30) [2/17/2007 5: 58 :59 AM] Ebook banner... r Defining Strings Using . for Web Programming and Administration http://docs.rinet.ru:8080/P7/ (8 of 30) [2/17/2007 5: 58 :58 AM] Day 9 Using Subroutines What Is a Subroutine?● Defining and Invoking a Subroutine Forward References. with Subroutines● Specifying the Sort Order● Predefined Subroutines Creating Startup Code Using BEGIN❍ Creating Termination Code Using END❍ Handling Non-Existent Subroutines Using AUTOLOAD❍. with Pagination❍ ● Formatting Long Character Strings Eliminating Blank Lines When Formatting❍ Supplying an Indefinite Number of Lines❍ ● Formatting Output Using printf● Summary● Q&A●

Ngày đăng: 25/03/2014, 10:30

Từ khóa liên quan

Mục lục

  • docs.rinet.ru

    • Ebook banner rotater for Web Programming and Administration

    • 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