Perl Tutorials - Herong's Tutorial Examples - Version 5.30, by Dr. Herong Yang

Perl Tutorials - Herong's Tutorial Examples

Copyright © 1995-2014 by Dr. Herong Yang. All rights reserved. This Perl tutorial book is a collection of notes and sample codes written by the author while he was learning Perl language himself. Topics include ActivePerl, data types, subroutines, debug, references, objects, open, binary, file, directory, DBM, MySQL, regular expression, RPC::XML, XML::Simple, SOAP::Lite, socket, CGI, IIS, socket, Windows, Linux.

Table of Contents

About This Book

Perl on Linux Systems

Perl Installation on Linux Systems

Running Perl Scripts on Linux Systems

ActivePerl on Windows Systems

What Is ActivePerl?

Installing ActivePerl v5.18.1 on Windows Systems

Running Perl Scripts on Windows Systems

Installing ActivePerl v5.8.8 on Windows Systems

Data Types: Values and Variables

Scalar Values and List Values

Scalar Value Constructors

Scalar Value Interpretation

List Value Constructors

Variables - Scalar, Array and Hash

Using Scalar Variables

Using Array Variables

Using Hash Variables

"undef" Value and Undefined Variables

Expressions, Operations and Simple Statements

What Is an Expression?

Expression Evaluation Context

Simple Statements and Modifiers

User Defined Subroutines

Declaring and Calling Subroutines - Example on Parameter List - Example on Parameters as Alias - Example on Return Values - Example on Calling Formats

Perl Built-in Debugger

Commonly Used Debugging Commands

Debugging Tutorial Session

Name Spaces and Perl Module Files

Including Script Codes from Other Files

do() Function - Including Script Files

require() Function - Including Script Files

"package" Statement - Switching Name Space

BEGIN(), CHECK(), INIT() and END() Functions

Defining Your Own Perl Module - A Sample Perl Module

Symbolic (or Soft) References

Using Symbolic References

$$name - Replacing Identifiers by Scalar Variables

${EXPR} - Replacing Identifiers by Expressions

EXPR->* - The Dereference Operator

$$$name - Nested Symbolic References

Hard References - Addresses of Memory Objects

\* - Creating Hard References

Using Hard References

$$name - Replacing Identifiers by Scalar Variables

${EXPR} - Replacing Identifiers by Expressions

EXPR->* - The Dereference Operator

$$$name - Nested Hard References

\$b-\$a - Using Hard References in Other Operations

Objects (or References) and Classes (or Packages)

Basic Concepts of Classes and Objects

Invoking Package Subroutines as Class Methods

bless() - Converting References to Objects

Invoking Package Subroutines as Object Methods

Class Variables and Object Variables

new() Method - Creating Objects by the Class - A Perl Class Example

Typeglob and Importing Identifiers from Other Packages

Typeglob, Symbolic Table and Identifier Aliases

Accessing Identifiers from Other Packages as Aliases

Exporting and Importing Package Identifiers

String Built-in Functions and Performance

String Related Built-in Functions

Performance of Perl substr() and index()

Performance of Java substring() and indexOf()

File Handles and Data Input/Output

open() - Opening File Handles for Input and Output

print() - Printing Output to File Handles

<file_handle> - Reading Data from File Handles

Open Files in Binary Mode

binmode() - Opening Files for Binary Input

binmode() - Opening Files for Binary Output - Copying Binary Files - Converting Binary Data to Hex Numbers

Open Directories and Read File Names

opendir() - Open Directory to Read File Names - Sample Program to Read Directories - Displaying the Directory Tree - Searching Text in Directory Files

File System Functions and Operations

Built-in Functions to Work with the File System

File Test Operators

stat() - Returns File Statistics

Converting Perl Script to Executable Binary

Perl Script Conversion Tools

Installing Perl Dev Kit (PDK)

Running PerlApp to Convert *.pl to *.exe

Using DBM Database Files

dbmopen() - Opening DBM Files with Hash Variables

DBM Database Example - English French Dictionary

DBM Database Example - Book Records with Multiple Fields

Using MySQL Database Server

Installing Database Module for MySQL - My First Perl Program with MySQL

Socket Communication Over the Internet

What Is Socket Communication?

connect() - Establishing a Socket Communication - A Simple Socket Server Program - A Simple Socket Client Program

gethostbyaddr() - Network Utility Functions - The Socket Module

XML::Simple Module - XML Parser and Generator

XMLin() and XMLout() Methods

XML Parsing Options

"forcearray" - Forcing Element Contents as Arrays

"suppressempty" - Parsing Empty Elements

"keyattr" - Namings Attributes as Keys - XML Hash Example

XML Communication Model

XML Messages over Socket Connections - XML Communication Server Example - XML Communication Client Example

SOAP::Lite - SOAP Server-Client Communication Module

What Is SOAP?

What Is SOAP::Lite?

SOAP::Transport::TCP - SOAP Server with TCP Protocol - SOAP Client Example with TCP Protocol

SOAP::Lite Tracing Functions

SOAP::Transport::HTTP - SOAP Server with HTTP Protocol

Perl Programs as IIS Server CGI Scripts

Configuring IIS 5.0 for Perl Programs

perl.exe vs. perlis.dll

CGI (Common Gateway Interface)

What Is Common Gateway Interface (CGI)?

IIS Environment Variables

QUERY_STRING - CGI Query String - CGI Application Example

XML-RPC - Remote Procedure Call with XML and HTTP

What Is XML-RPC?

Defining a Remote Method Call in XML

Sending a Remote Method Call as a HTTP Request

Defining Returning Values of a Remote Method Call

Receiving Returning Values as a HTTP Response

RPC::XML - Perl Implementation of XML-RPC

What Is RPC::XML?

RPC::XML::Server - XML-RPC Server Interface Class

RPC::XML Client and Data Classes

Installing NMake 1.5

Installing RPC::XML Module - RPC::XML Server Sample Program - RPC::XML Client Sample Program

Sending Arrays with Remote Method Calls

Integrating Perl with Apache Web Server

Downloading Apache HTTP Server 2.2.25 for Windows

Installing Apache HTTP Server 2.2.25 on Windows

Publishing HTML Documents as Web Pages

Starting and Stopping Apache Server

Running Perl Scripts in "cgi-bin" - Testing Perl CGI Environment

500 Internal Server Error - The Standard Library for CGI Scripts

ReadParse() - Parsing Web Form Input Values

Running Perl Scripts in "htdocs" Module for Building Web Pages

What Is

Generating HTML Document with

Retrieving Query Parameters and Headers

Retrieving Environment and Script Information

Redirecting Browser to a URI

"Refresh" http-equiv Meta Tag

What Is CGI::Cookie?

Retrieving and Setting HTTP Cookies

LWP::UserAgent and Web Site Testing

What Is LWP::UserAgent?

What Is HTTP::Response?

What Is HTTP::Request? - Sending a GET Request - Following HTTP Redirects

http-equiv="Refresh" Meta Tag not Followed - Posting Form Data

post() Method not Following Redirect Location - Posting with Redirects

What Is HTTP::Cookies? - GET, POST and Cookies - Login to

HTTP::Cookies save() not Saving Temporary Cookies - Sending Request with Cookies


Printable Copy - PDF Version

Keywords: Perl, Script, Language, Tutorial, Example

Table of Contents - Updated in 2014, by Dr. Herong Yang