4

Practical Perl Programming

  • Upload
    others

  • View
    19

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Practical Perl Programming
  • Practical Perl Programming
  • Contents
  • Introduction to Perl
  • What is Perl?
  • Origins
  • Similar to C?
  • Cost and Licensing
  • Installing Perl Installed
  • Getting and Installing Perl
  • Writing Perl Programs
  • Creating the Program
  • Invocation
  • Comments in Your Program
  • Further Reading/Information
  • Numeric and String Literals
  • Numeric Literals
  • Example: Numbers
  • String Literals
  • Example: Single-Quoted Strings
  • Example: Double-Quoted Strings
  • Example: Back-Quoted Strings
  • Variables
  • Scalar Variables
  • Defining Scalar Variables
  • String Scalar Variables
  • Arrays
  • What is an Array?
  • Literal Arrays
  • Indexed Arrays
  • Some Useful Array Functions
  • Associative Arrays
  • Associative Array Operators
  • Operators
  • The Binary Arithmetic Operators
  • The Unary Arithmetic Operators
  • The Logical Operators
  • The Bitwise Operators
  • Comparison operators for numbers and strings
  • The Range Operator (..)
  • The String Operators (. and x)
  • Order of Precedence
  • Perl Statements
  • Understanding Expressions
  • Statement Blocks
  • Statement Blocks and Local Variables
  • If/Unless statement
  • The for statement
  • The while/until statement
  • The foreach statement
  • Functions
  • Using the Parameter Array (@_)
  • Passing Parameters by Reference
  • Scope of Variables
  • Using a List as a Function Parameter
  • Nesting Function Calls
  • Using a Private Function
  • String Functions
  • Array Functions
  • Summary
  • References
  • Reference Types
  • Passing Parameters to Functions
  • The ref() Function
  • Example: Creating a Data Record
  • Interpolating Functions Inside Double-Quoted Strings
  • Summary
  • Files -- Input and Output in Perl
  • Some Files Are Standard
  • Using the Diamond Operator (<>)
  • File Test Operators
  • File Functions
  • Reading Directories
  • Reading and Writing Files
  • Binary Files
  • Getting File Statistics
  • Printing Revisited
  • Regular Expressions
  • What are regular Expressions
  • Using Regular Expressions
  • Special pattern matching character operators
  • Backtracking
  • Setting the Target Operator (Binding)
  • Substitution
  • The Matching Operator (m//)
  • The Matching Options
  • The Translation Operator (tr///)
  • The Translation Options
  • The Binding Operators
  • Character Classes
  • Quantifiers
  • Pattern Memory
  • Pattern Precedence
  • Extension Syntax
  • Pattern Examples
  • Some Practical Examples
  • Using the Match Operator
  • Using the Substitution Operator
  • Example: Using the Translation Operator
  • Example: Using the Split() Function
  • Reports
  • Format Statements
  • Field Lines
  • Report Headings
  • Special Variables
  • What Are the Special Variables?
  • Example: Using the DATA File Handle
  • Example: Using the %ENV Variable
  • Handling Errors and Signals
  • Checking for Errors
  • Using errno
  • Using the || Logical Operator
  • Using the die() Function
  • Using the warn() Function
  • Trapping Fatal Errors
  • Using the eval() Function
  • Signals
  • How to Handle a Signal
  • Objects in Perl
  • What are objects?
  • Classes
  • Abtraction
  • Polymorphism:Overriding Methods
  • Encapsulation:Keeping Code and Data Together
  • Objects in Perl
  • Bless the Hash and Pass the Reference
  • Initializing Properties
  • Using Named Parameters in Constructors
  • Inheritance: Perl Style
  • Polymorphism
  • One Class Can Contain Another
  • Static Versus Regular Methods and Variables
  • Perl Modules
  • Module Constructors and Destructors
  • The BEGIN Block
  • The END Block
  • Symbol Tables
  • The use Compiler Directive
  • Pragma in Perl
  • The strict Pragma
  • The Standard Modules
  • strict, my() and Modules
  • Module Examples
  • The Carp Module
  • The English Module
  • The Env Module
  • Debugging Perl
  • Syntax Errors
  • Common Syntax Errors
  • Logic Errors
  • Using the -w Command-Line Option
  • Being Strict with Your Variables
  • Stepping Through Your Script
  • Displaying Information
  • Examples: Using the n Command
  • Using Breakpoints
  • Creating Command Aliases
  • Using the Debugger as an Interactive Interpreter
  • Summary
  • Perl Command-Line Options
  • How Are the Options Specified?
  • The Command-line Options
  • Example uses of command-line options
  • Using the -0 Option
  • Using the -n and -p Options
  • Using the -i Option
  • Using the -s Option
  • Summary
  • Networking with Perl
  • Sockets
  • Clients and Servers
  • The Server Side of a Conversation
  • The Client Side of a Conversation
  • Using the Time Service
  • Sending Mail (SMTP)
  • The MAIL Command
  • The RCPT Command
  • The DATA Command
  • Reporting Undeliverable Mail
  • Using Perl to Send Mail
  • Receiving Mail (POP)
  • Checking for Upness (Echo)
  • Transferring Files (FTP)
  • The World Wide Web (HTTP)
  • CGI Programming in Perl
  • CGI Scripting
  • What is a CGI Script?
  • Writing and Running CGI Scripts
  • Why Use Perl for CGI?
  • CGI Apps versus Java Applets
  • Should You Use CGI Modules?
  • How Does CGI Work?
  • Calling Your CGI Program
  • Beginning CGI Programming in Perl
  • CGI Script Output
  • A First Perl CGI Script
  • Exectiion of CGI Programs
  • Why Are File Permissions Important in UNIX?
  • HTTP Headers
  • CGI and Environment Variables
  • URL Encoding
  • Security
  • CGIwrap and Security
  • The Other Side of CGI:Input -- HTML Forms
  • A Brief Overview of HTML
  • Server-Side Includes
  • Forms: Facilitating User Input and Interaction
  • Forms and CGI: What are they?
  • Some Example Forms
  • The FORM Tag
  • Entering Data
  • The Submit Button
  • Text Input
  • Password
  • Associating labels with text and password input
  • Radio Buttons
  • Checkboxes
  • Assigning Initial Input Values to
  • Select
  • Textarea
  • Hidden Input
  • An Example Form
  • HTML Forms as an Interface to Databases
  • Further Information
  • CGI Script Input: Accepting Input To Perl Scripts
  • Accepting Input from the Browser
  • Passing Data to a CGI Script
  • A Simple Form CGI Script Call
  • The Other Side -- receiving and processing information in CGI ( Perl) script
  • cgi-lib.pl
  • The cgi.pm module
  • A Minimal Form Response CGI Perl Script
  • Multiple argument input to a Perl CGI script
  • Some Example Perl CGI Scripts
  • RGBtoHex: an RGB to Hexidecimal Color Converter
  • An Address Book Search Engine
  • Creating a Guest Book
  • A Web Page Counter
  • Using Perl with Web Servers
  • Server Log Files
  • Reading a Log File In Perl
  • Listing Access by Document
  • Looking at the Status Code
  • Existing Log File Analyzing Programs
  • Creating Your Own CGI Log File
  • Internet Resources
  • Web Sites
  • A Quick Quide to HTML
  • Basic HTML Programming
  • HTML
  • Hypertext Terminology
  • Creating HTML Documents
  • Learning HTML
  • Anatomy of Any HTML Document
  • HTML Tags
  • Basic HTML Page Structure
  • Summary of Basic HTML Tags
  • Bare-bones example of HTML
  • Basic HTML Coding
  • Head elements
  • The Body Element
  • Headings
  • Paragraphs
  • Comments
  • Links and Anchors
  • Linking to Other Documents
  • Relative, Absolute and remote Links
  • Anchors
  • Lists
  • Unordered or Bulleted lists
  • Ordered or Numbered lists
  • Glossary or Definition Lists
  • Nesting Lists
  • Preformatted Text
  • In-Line Images
  • External Images, Sounds, Video
  • Things to remember when HTML programming
  • Text Formatting with HTML
  • Logical Character Formatting
  • Physical Character formatting
  • Special Characters
  • Horizontal rules and Line breaks
  • Fonts and Font Sizes
  • Recommended Reading
  • About this document ...
  1. OOFKHBDGEFBFPAEMKAHPKJMKLEJBGHKP:
    1. form1:
      1. f1:
      2. x:
        1. f2:
    2. form2:
      1. x:
        1. f1:
        2. f2:
        3. f3: [chartreuse]
        4. f4: african
        5. f5:
      2. f6:
  2. EIBGHFPNGKNOCHJMFLNGGKHDLLGGCMCF:
    1. form1:
      1. f1:
    2. form2:
      1. f1:
    3. form3:
      1. x:
        1. f1: left
        2. f3: right
        3. f5: up
        4. f7: down
      2. f2:
      3. f4:
      4. f6:
      5. f8:
  3. JEELDDPJJFDEJHGNBDJHLOAMBJLMOEGO:
    1. form1:
      1. x:
        1. f1:
    2. form2:
      1. x:
        1. f1:
  4. FOHGCHGLMLDBOPPOOKBOCCGLIDPNJIGK:
    1. form1:
      1. x:
        1. f1:
  5. HPCBKGFBDIGILOHPCCLGLNKGJBDCGOBN:
    1. form1:
      1. x:
        1. f1:
        2. f2:
  6. GFNBHGPNIACDADFAEENGLHHLEGKADDGE:
    1. form1:
      1. x:
        1. f1: Off
  7. EDPDBJBNPKPBKCPLAJFPEAGCLMJCMKNE:
    1. form1:
      1. x:
        1. f1: Off
        2. f2: Off
        3. f3: Off
        4. f4: Off
        5. f5: Off
        6. f6: Off
  8. JOAEOFHNDOAPNJLDMCGAFDDFJFFIEEBG:
    1. form1:
      1. x:
        1. f1: Y
  9. BLDFMEDBGBOBCCAJJLDFJNGKFHAPKEEM:
    1. form1:
      1. x:
        1. f1: [ Europe]
  10. KDNHDDGFJCKMADLADHNILFJPLIABGHIF:
    1. form1:
      1. x:
        1. f1:
    2. form2:
      1. x:
        1. f1: Please type here...
  11. FACEIPJNOOKDBHIPOPJCMOKAMAEGPJLL:
    1. form1:
      1. f1:
      2. x:
        1. f2:
  12. EPACCLHIFLEDAPIFKEBJIGKJOEBGKFLP:
    1. form1:
      1. x:
        1. f1:
        2. f2:
        3. f3: [chartreuse]
        4. f4: african
        5. f5:
      2. f6:
  13. OCIEDKOBKJMPNBIPBIJCCNCHCMGLCIBJ:
    1. form1:
      1. x:
        1. f1:
        2. f2:
        3. f3:
      2. f4:
      3. f5:
  14. PDDJOPHBNGAEODDIFNKBIKBFBGKHFALK:
    1. form1:
      1. x:
        1. f1:
        2. f2:
        3. f3:
        4. f4:
        5. f5:
        6. f6:
      2. f7:
      3. f8:
  15. GIIJGOOGFFPKKNKAPFDBAEKFHBCHAKGJ:
    1. form1:
      1. x:
        1. f1:
        2. f2:
        3. f3:
      2. f4:
      3. f5: