Learning Perl on Win32 Systems

Book description

In this smooth, carefully paced course, leading Perl trainers and a Windows NT practitioner teach you to program in the language that promises to emerge as the scripting language of choice on NT. With a foreword by Larry Wall, the creator of Perl, this book is the "official" guide for both formal (classroom) and informal learning. Based on the "llama book," Learning Perl on Win32 Systems features tips for PC users and new NT-specific examples. Perl for Win32 is a language for easily manipulating text, files, user and group profiles, performance and event logs, and registry entries, and a distribution is available on the Windows NT Resource Kit. Peer-to-peer technical support is now available on the perl.win32.users mailing list. The contents include:

  • An introduction to "the Perl way" for Windows users

  • A quick tutorial stroll through Perl in one lesson

  • Systematic, topic-by-topic coverage of Perl's broad capabilities

  • Innumerable, brief code examples

  • Programming exercises for each topic, with fully worked-out answers

  • Access to NT system functions through Perl

  • Database access with Perl

  • CGI programming with Perl

Erik Olson is director of advanced technologies for Axiom Technologies, LC, where he specializes in providing Win32 development solutions. Randal L. Schwartz and Tom Christiansen have also written Programming Perl, co-authored with Larry Wall and published by O'Reilly & Associates.

Table of contents

  1. Learning Perl on Win32 Systems
    1. Foreword to the First Edition of Learning Perl
    2. Foreword to the Present Edition
    3. Preface
      1. What This Book Is About
      2. We’d Like to Hear from You
      3. Conventions
      4. Exercises
        1. FTP
        2. FTPMAIL
      5. Acknowledgments for First Edition
      6. Acknowledgments for the Second Edition
      7. Acknowledgments for the Win32 Edition
    4. 1. Introduction
      1. History of Perl
      2. Purpose of Perl
      3. Availability
        1. ActiveState Perl for Win32
        2. Standard Perl Distribution
        3. Windows NT and Windows 95
      4. Support
      5. Basic Concepts
        1. Documentation
      6. A Stroll Through Perl
        1. The “Hello, world” Program
        2. Asking Questions and Remembering the Result
        3. Adding Choices
        4. Guessing the Secret Word
        5. More than One Secret Word
        6. Giving Each Person a Different Secret Word
        7. Handling Varying Input Formats
        8. Making It Fair for the Rest
        9. Making It a Bit More Modular
        10. Moving the Secret Word List into a Separate File
        11. Ensuring a Modest Amount of Security
        12. Warning Someone When Things Go Astray
        13. Many Secret Word Files in the Current Directory
        14. Listing the Secret Words
        15. Making Those Old Word Lists More Noticeable
        16. Maintaining a Last-Good-Guess Database
        17. The Final Programs
      7. Exercises
    5. 2. Scalar Data
      1. What Is Scalar Data?
      2. Numbers
        1. All Numbers Use the Same Format Internally
        2. Float Literals
        3. Integer Literals
      3. Strings
        1. Single-Quoted Strings
        2. Double-Quoted Strings
      4. Scalar Operators
        1. Operators for Numbers
        2. Operators for Strings
        3. Operator Precedence and Associativity
        4. Conversion Between Numbers and Strings
      5. Scalar Variables
      6. Scalar Operators and Functions
        1. Binary Assignment Operators
        2. Autoincrement and Autodecrement
        3. The chop( ) and chomp( ) Functions
        4. Interpolation of Scalars into Strings
      7. <STDIN> as a Scalar Value
      8. Output with print
      9. The Undefined Value
      10. Exercises
    6. 3. Arrays and List Data
      1. What Is a List or Array?
      2. Literal Representation
      3. Variables
      4. Array Operators and Functions
        1. Assignment
        2. Array Element Access
        3. The push and pop Functions
        4. The shift and unshift Functions
        5. The reverse Function
        6. The sort Function
        7. The chomp Function
      5. Scalar and List Context
      6. <STDIN> as an Array
      7. Variable Interpolation of Arrays
      8. Exercises
    7. 4. Control Structures
      1. Statement Blocks
      2. The if/unless Statement
      3. The while/until Statement
      4. The do {} while/until Statement
      5. The for Statement
      6. The foreach Statement
      7. Exercises
    8. 5. Hashes
      1. What Is a Hash?
      2. Hash Variables
      3. Literal Representation of a Hash
      4. Hash Functions
        1. The keys Function
        2. The values Function
        3. The each Function
        4. The delete Function
      5. Hash Slices
      6. Exercises
    9. 6. Basic I/O
      1. Input from STDIN
      2. Input from the Diamond Operator
      3. Output to STDOUT
        1. Using print for Normal Output
        2. Using printf for Formatted Output
      4. Exercises
    10. 7. Regular Expressions
      1. Concepts About Regular Expressions
      2. Simple Uses of Regular Expressions
      3. Patterns
        1. Single-Character Patterns
        2. Grouping Patterns
          1. Sequence
          2. Multipliers
          3. Parentheses as memory
          4. Alternation
        3. Anchoring Patterns
        4. Precedence
      4. More on the Matching Operator
        1. Selecting a Different Target (the =~ Operator)
        2. Ignoring Case
        3. Using a Different Delimiter
        4. Using Variable Interpolation
        5. Special Read-Only Variables
      5. Substitutions
      6. The split and join Functions
        1. The split Function
        2. The join Function
      7. Exercises
    11. 8. Functions
      1. Defining a User Function
      2. Invoking a User Function
      3. Return Values
      4. Arguments
      5. Private Variables in Functions
      6. Semiprivate Variables Using local
      7. File-Level my( ) Variables
      8. Exercises
    12. 9. Miscellaneous Control Structures
      1. The last Statement
      2. The next Statement
      3. The redo Statement
      4. Labeled Blocks
      5. Expression Modifiers
      6. &&, ||, and ?: as Control Structures
      7. Exercises
    13. 10. Filehandles and File Tests
      1. What Is a Filehandle?
      2. Opening and Closing a Filehandle
      3. Using Pathnames and Filenames
      4. A Slight Diversion: die
      5. Using Filehandles
      6. The -x File Tests
      7. The stat Function
      8. Exercises
    14. 11. Formats
      1. What Is a Format?
      2. Defining a Format
      3. Invoking a Format
      4. More About the Fieldholders
        1. Text Fields
        2. Numeric Fields
        3. Multiline Fields
        4. Filled Fields
      5. The Top-of-Page Format
      6. Changing Defaults for Formats
        1. Using select to Change the Filehandle
        2. Changing the Format Name
        3. Changing the Top-of-Page Format Name
        4. Changing the Page Length
        5. Changing the Position on the Page
      7. The FileHandle Module
      8. Exercises
    15. 12. Directory Access
      1. Moving Around the Directory Tree
      2. Globbing
      3. Directory Handles
      4. Opening and Closing a Directory Handle
      5. Reading a Directory Handle
      6. Exercises
    16. 13. File and Directory Manipulation
      1. Removing a File
      2. Renaming a File
      3. Making and Removing Directories
      4. Modifying Permissions
      5. Modifying Timestamps
      6. Exercises
    17. 14. Process Management
      1. Using system and exec
      2. Using Backquotes
      3. Using Processes as Filehandles
      4. Summary of Process Operations
      5. Win32::Process
      6. Exercises
    18. 15. Other Data Transformation
      1. Finding a Substring
      2. Extracting and Replacing a Substring
      3. Formatting Data with sprintf( )
      4. Advanced Sorting
      5. Transliteration
      6. Exercises
    19. 16. System Information
      1. Getting User and Machine Information
      2. Packing and Unpacking Binary Data
      3. Getting Network Information
      4. The Registry
        1. The Registry Structure
      5. Opening and Reading Registry Values
      6. Setting Registry Values
        1. More Registry Operations
      7. Exercises
    20. 17. Database Manipulation
      1. DBM Databases and DBM Hashes
      2. Opening and Closing DBM Hashes
      3. Using a DBM Hash
      4. Fixed-Length Random-Access Databases
      5. Variable-Length ( Text) Databases
      6. Win32 Database Interfaces
      7. Exercises
    21. 18. CGI Programming
      1. The CGI.pm Module
      2. Your CGI Program in Context
      3. Simplest CGI Program
      4. Passing Parameters via CGI
        1. Less Typing
        2. Form Generation
        3. Other Form Elements
        4. References
        5. Fancier Calling Sequences
      5. Creating a Guestbook Program
        1. Object-Oriented Programming in Perl
        2. Objects in CGI.pm
      6. Troubleshooting CGI Programs
      7. Perl and the Web: Beyond CGI Programming
        1. Custom Publishing Systems
        2. PerlIS and PerlScript
      8. Further Reading
      9. Exercises
    22. 19. OLE Automation
      1. Introduction to OLE Automation
      2. Creating Automation Objects
      3. Using Automation Objects
        1. Data-Access Objects
      4. Variants
      5. Tips and Techniques
        1. Translating Samples from Visual Basic
      6. Exercises
    23. A. Exercise Answers
      1. Chapter 2
      2. Chapter 3
      3. Chapter 4
      4. Chapter 5
      5. Chapter 6
      6. Chapter 7
      7. Chapter 8
      8. Chapter 9
      9. Chapter 10
      10. Chapter 11
      11. Chapter 12
      12. Chapter 13
      13. Chapter 14
      14. Chapter 15
      15. Chapter 16
      16. Chapter 17
      17. Chapter 18
      18. Chapter 19
    24. B. Libraries and Modules
      1. Library Terminology
      2. Standard Modules
        1. General Programming: Miscellaneous
        2. General Programming: Error Handling and Logging
        3. General Programming: File Access and Handling
        4. General Programming: Classes for I/O Operations
        5. General Programming: Text Processing and Screen Interfaces
        6. Database Interfaces
        7. Mathematics
        8. The World Wide Web
        9. Networking and Interprocess Communication
        10. Automated Access to the Comprehensive Perl Archive Network
        11. Time and Locale
        12. Object Interfaces to Built-in Functions
        13. For Developers: Autoloading and Dynamic Loading
        14. For Developers: Language Extensions and Platform Development Support
        15. For Developers: Object-Oriented Programming Support
      3. CPAN: Beyond the Standard Library
      4. Win32 Extensions
    25. C. Networking Clients
      1. A Simple Client
      2. A Webget Client
    26. D. Topics We Didn’t Mention
      1. Full Interprocess Communications
      2. The Debugger
      3. The Command Line
      4. Other Operators
      5. Many, Many More Functions
        1. grep and map
        2. The eval Operator (and s///e)
      6. Many, Many Predefined Variables
      7. Symbol Table Manipulation With *FRED
      8. Additional Regular Expression Features
      9. Packages
      10. Embeddible, Extensible
        1. Security Matters
        2. Switch or Case Statements
        3. Direct I/O: sysopen, sysread, syswrite, and sysseek
        4. The Perl Compiler
        5. Database Support
        6. Complex Data Structures
        7. Function Pointers
      11. And Other Stuff
    27. Index
    28. Colophon

Product information

  • Title: Learning Perl on Win32 Systems
  • Author(s): Randal L. Schwartz, Erik Olson, Tom Christiansen
  • Release date: August 1997
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781565923249