Description
Efnisyfirlit
- Title Page
- Copyright Page
- Contents at a Glance
- Table of Contents
- About the Author
- About the Technical Reviewers
- Acknowledgments
- Introduction
- CHAPTER 1 First Steps in Perl
- Programming Languages
- Our First Perl Program
- Program Structure
- Documenting Your Programs
- Keywords
- Statements and Statement Blocks
- Character Sets
- Escape Sequences
- Whitespace
- Number Systems
- The Perl Debugger
- Summary
- Exercises
- CHAPTER 2 Scalars
- Types of Data
- Numbers
- Binary, Hexadecimal, and Octal Numbers
- Strings
- Single- vs. Double-Quoted Strings
- q// and qq//
- Here-Documents
- Converting Between Numbers and Strings
- Operators
- Numeric Operators
- Arithmetic Operators
- Bitwise Operators
- Truth and Falsehood
- Boolean Operators
- String Operators
- String Comparison
- Operators to Be Covered Later
- Operator Precedence
- Variables
- Scoping
- Variable Names
- The Special Variable $_
- Variable Interpolation
- Currency Converter
- Introducing
- The chomp() and chop() Functions
- Two Miscellaneous Functions
- The exit() Function
- The die() Function
- Summary
- Exercises
- CHAPTER 3 Control Flow Constructs
- The if Statement
- Operators Revisited
- Comparing Numbers
- Comparing Strings
- Other Tests
- Logical Operators
- Multiple Choice: if . . . else
- Even More Choices: if . . . elsif . . . else
- The unless Statement
- Expression Modifiers
- Using Short-Circuited Evaluation
- Looping Constructs
- The while Loop
- while (
) - Infinite Loops
- Looping Until
- The for Loop
- The foreach Loop
- do .. while and do .. until
- Expression Modifying
- Loop Control Constructs
- Breaking Out
- Going On to the Next
- Reexecuting the Loop
- Loop Labels
- goto
- Summary
- Exercises
- CHAPTER 4 Lists and Arrays
- Lists
- Simple Lists
- More Complex Lists
- Creating Lists Easily with qw//
- Ranges
- Accessing List Values
- List Slices
- Combining Ranges and Slices
- Arrays
- Assigning Arrays
- Scalar vs. List Context
- Adding to an Array
- Accessing an Array
- Accessing Single Elements
- $#array
- Looping Through an Array with Indexes
- Accessing Multiple Elements
- Processing Arrays with the foreach Loop
- Choosing an Iterator
- Modifying the Value of an Iterator
- Expression Modifier for the foreach Loop
- Array Functions
- Summary
- Exercises
- CHAPTER 5 Hashes
- Creating a Hash
- Working with Hash Values
- Adding, Changing, and Removing Elements
- Hash in List Context
- Hash in Scalar Context
- Hash Functions
- The keys() Function
- The values() Function
- The each() Function
- The delete() Function
- The exists() Function
- Hash Examples
- Creating Readable Variables
- “Reversing” Information
- Counting Things
- Summary
- Exercises
- CHAPTER 6 Subroutines/Functions
- Understanding Subroutines
- Defining a Subroutine
- Invoking a Subroutine
- Order of Declaration and Invoking Functions
- Passing Arguments into Functions
- Return Values
- The return Statement
- Understanding Scope
- Global Variables
- Introduction to Packages
- Lexical Variables (aka Local Variables)
- Some Important Notes on Passing Arguments
- Function Arguments Passed by Reference
- Lists Are One-Dimensional
- Default Argument Values
- Named Parameters
- Summary
- Exercises
- CHAPTER 7 Regular Expressions
- What Are They?
- Patterns
- Interpolation
- Metacharacters and Escaping
- Anchors
- Shortcuts and Options
- Alternatives
- Repetition with Quantifiers
- Summary Table
- Memory and Backreferences
- How the Regular Expression Engine Works
- Working with Regexes
- Substitution
- Changing Delimiters
- Modifiers
- The split() Function
- The join() Function
- Common Blunders
- Backreferences (Again)
- Summary
- Exercises
- CHAPTER 8 Files and Data
- Filehandles
- The open() Function
- The close() Function
- Three Ways to Open a File
- Read Mode
- Write Mode
- Append Mode
- Reading in Scalar Context
- Reading with the Diamond
- @ARGV: The Command-Line Arguments
- @ARGV and <>
- $ARGV
- Reading in List Context
- Writing to Files
- Buffering
- Opening Pipes
- Receiving Piped Data from a Process
- Sending Piped Data to Another Process
- Bidirectional Pipes
- File Tests
- Summary
- Exercises
- CHAPTER 9 String Processing
- Character Position
- String Functions
- The length() Function
- The index() Function
- The rindex() Function
- The substr() Function
- Transliteration
- Summary
- Exercises
- CHAPTER 10 Interfacing to the Operating System
- The %ENV Hash
- Working with Files and Directories
- File Globbing with glob()
- Reading Directories
- Functions to Work with Files and Directories
- The chdir() Function
- The unlink() Function
- The rename() Function
- The link(), symlink(), and readlink() Functions
- The mkdir() and rmdir() Functions
- The chmod() Function
- An Example
- Executing External Programs
- The system() Function
- Backquotes
- There’s More
- Summary
- Exercises
- CHAPTER 11 References
- What Is a Reference?
- Anonymity
- The Life Cycle of a Reference
- Reference Creation
- Anonymous Arrays and Anonymous Hashes
- Using References
- Array Elements
- Reference Modification
- Hash References
- Notation Shorthand Using ->
- Reference Counting and Destruction
- Counting Anonymous References
- Using References for Complex Data Structures
- Matrices
- Autovivification
- Trees
- Summary
- Exercises
- CHAPTER 12 Modules
- Why Do We Need Them?
- Creating a Module
- Including Other Files with use
- do
- require
- use
- Changing @INC
- Package Hierarchies
- Exporters
- The Perl Standard Modules
- Online Documentation
- Data::Dumper
- File::Find
- Getopt::Std
- Getopt::Long
- File::Spec
- Benchmark
- Win32
- Win32::Sound
- Win32::TieRegistry
- CPAN
- Installing Modules with PPM
- Installing a Module Manually
- The CPAN Module
- Bundles
- Bundle::LWP
- Bundle::libnet
- Submitting Your Own Module to CPAN
- Summary
- CHAPTER 13 Object-Oriented Perl
- OO Buzzwords
- Objects
- Attributes
- Methods
- Classes
- Polymorphism
- Encapsulation
- Inheritance
- Constructors
- Destructors
- An Example
- Rolling Your Own Classes
- Bless You, My Reference
- Storing Attributes
- The Constructor
- Considering Inheritance
- Providing Attributes
- Creating Methods
- Get-Set Methods
- Class Attributes
- Privatizing Your Methods
- Utility Methods
- Death of an Object
- The Finished Class
- Do You Need OO?
- Are Your Subroutines Tasks?
- Do You Need Persistence?
- Do You Need Sessions?
- Do You Need Speed?
- Do You Want the User to Be Unaware of the Object?
- Are You Still Unsure?
- Summary
- Exercises
- CHAPTER 14 Introduction to CGI
- We Need a Web Server
- Creating a CGI Directory
- Writing CGI Programs
- “hello, world!” in CGI
- What to Do If Things Go WrongWhat if you don’t see the warm, friendly greeting
- The CGI Environment
- Generating HTML
- Introducing CGI.pm
- Conventional Style of Calling Methods
- CGI.pm Methods
- Methods That Generate Several Tags
- Named Parameters
- Methods That Generate One Tag
- Providing Attributes
- Processing Form Data
- The param() Method
- Dynamic CGI
- Let’s Play Chess!
- Improvements We Can Make
- What We Did Not Talk About
- Summary
- Exercises
- CHAPTER 15 Perl and DBI
- Introduction to Relational Databases
- We Need an SQL Server—MySQL
- Testing the MySQL Server
- Creating a Database
- The CREATE DATABASE Command
- The USE Command
- The CREATE TABLE Command
- The DESCRIBE Command
- Creating a Non-root User with the GRANT Command
- The INSERT Command
- The SELECT Command
- The WHERE Clause
- The ORDER BY Clause
- More Complicated SELECTs
- Table Joins
- Introduction to DBI
- Installing DBI and the DBD::mysql
- Connecting to the MySQL Database
- Executing an SQL Query with DBI
- A More Complex Example
- Use Placeholders
- DBI and Table Joins
- Perl, DBI, and CGI
- What We Didn’t Talk About
- Summary
- Exercises
- APPENDIX Exercise Solutions
- Chapter 1
- Chapter 2
- Chapter 3
- Chapter 4
- Chapter 5
- Chapter 6
- Chapter 7
- Chapter 8
- Chapter 9
- Chapter 10
- Chapter 11
- Chapter 13
- Chapter 14
- Chapter 15
- Index
Reviews
There are no reviews yet.