Using Symbolic References

This section describes symbolic (or soft) references, replacing variable or function identifiers by string expressions. Curly brackets {} or the dereference operator -> is the best way of using symbolic references.

Symbolic references are scalar objects containing strings representing identifiers of variables and functions. Symbolic references are also called soft references. There are several ways to use symbolic references.

1. Directly placing a scalar variable that contains the referencing string in the place where the identifier should be. For example, $name = 'foo'; $$name = 10; print "$foo";

2. Placing an expression that returns the referencing string in curly brackets {} to replace the identifier. Curly brackets are also called lookups. String literals in lookups don't have to be quoted. For example, $name = 'foo'; ${$name.'l'} = 20; print "$fool";

3. If a symbolic reference is used to access a single element of an array, to access a single element of hash, or to call a function, you can remove the name space prefix character $, or &, and replace the identifier with an expression that returns the referencing string, then followed by the dereference operator: ->. For example, $name = 'foo'; $name->[0] = 30; print "$foo[0]";

4. Of course, symbolic references can be nested. For example, $a = 'b'; $b = 'c'; $c = 40; print "$$$a";

See next sections for more examples on symbolic references.

Table of Contents

 About This Book

 Perl on Linux Systems

 ActivePerl on Windows Systems

 Data Types: Values and Variables

 Expressions, Operations and Simple Statements

 User Defined Subroutines

 Perl Built-in Debugger

 Name Spaces and Perl Module Files

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

 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 Files in Binary Mode

 Open Directories and Read File Names

 File System Functions and Operations

 Converting Perl Script to Executable Binary

 Using DBM Database Files

 Using MySQL Database Server

 Socket Communication Over the Internet

 XML::Simple Module - XML Parser and Generator

 XML Communication Model

 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

 References

 PDF Printing Version