Perl Tutorials - Herong's Tutorial Examples - v6.01, by Dr. Herong Yang
Variables - Scalar, Array and Hash
This section describes Perl variable types: Scalar, Array, and Hash. Variable names must be prefixed with special symbols to indicate their types, $, @ and %.
Perl supports 3 types of variables: Scalar, Array, and Hash.
1. Scalar Variable - A variable to hold a scalar value. The name of a scalar variable must be prefixed with the dollar sign, $, and followed by an identifier, $identifier. For example: $price and $url.
2. Array Variable - A variable to hold a list value. The name of an array variable must be prefixed with the at sign, @, and followed by an identifier, @identifier. For example: @orders and @links.
3. Hash Variable - A variable to hold an associative array, which is a special list value - members are grouped as pairs of keys and values. The name of an array variable must be prefixed with the percent sign, %, and followed by an identifier, %identifier. For example: %priceList and %siteRanks.
Like in many other programming languages, a variable name identifier in Perl is a string beginning with a letter or underscore, and containing letters, underscores, and digits.
Variables for different data types are in different name spaces. You could use the same variable identifier for a scalar, an array, and a hash.
Table of Contents
►Data Types: Values and Variables
►Variables - Scalar, Array and Hash
"undef" Value and Undefined Variables
Expressions, Operations and Simple Statements
Name Spaces and Perl Module Files
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
File Handles and Data Input/Output
Open Directories and Read File Names
File System Functions and Operations
Socket Communication Over the Internet
XML::Simple Module - XML Parser and Generator
SOAP::Lite - SOAP Server-Client Communication Module
Perl Programs as IIS Server CGI Scripts
CGI (Common Gateway Interface)
XML-RPC - Remote Procedure Call with XML and HTTP
RPC::XML - Perl Implementation of XML-RPC
Integrating Perl with Apache Web Server
CGI.pm Module for Building Web Pages
LWP::UserAgent and Web Site Testing
Converting Perl Script to Executable Binary