Perl Tutorials - Herong's Tutorial Examples

© 2022 Dr. Herong Yang. All rights reserved.

Perl Tutorials 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 introduction of ActivePerl; data types, variables and expressions; scalars, arrays, hash maps, and references; input/output and file systems; DBM files and MySQL access; socket communication; generating executables; XML::Simple and RPC:XML modules; LWP::UserAgent, HTTP::Request and SOAP::Lite modules; CGI, and IIS/Apache integrations. Updated in 2022 (Version v6.01) with minor updates.

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?

Install ActivePerl on Windows Systems

Running Perl Scripts 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

Hard References - Addresses of Memory Objects

Objects (or References) and Classes (or Packages)

Typeglob and Importing Identifiers from Other Packages

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

Image and Picture Processing

Imager - Create and Save Image

Imager - Draw Graphical Elements

Imager - Convert Image File Format

Imager::File::PNG - PNG File Format

Install LIBPNG from Source Code

Install Imager::File::PNG Manually

Install PerlMagick from Source Code

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

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

Converting Perl Script to Executable Binary

Perl Script Conversion Tools

Installing Perl Dev Kit (PDK)

Running PerlApp to Convert *.pl to *.exe

Managing Perl Engine and Modules on macOS

Perl Version Pre-Installed on macOS

Install Xcode Command Line Tools

Configure CPAN Shell

Install Perl Module from CPAN

Install Perl Module from Source Code

Archived Tutorials

Archived: Install ActivePerl v5.18.1 on Windows Systems

Archived: Install ActivePerl v5.8.8 on Windows Systems


Full Version in PDF/EPUB

Keywords: Perl, Script, Language, Tutorial, Example