Using Hard References

This section describes how to use hard references - hard references are used in the same way as soft references by replacing identifier with a hard reference expression in curly brackets {}, or using the dereference operator ->.

Similar to soft (symbolic) references, there several syntax formats to use hard references:

1. Directly placing a scalar variable that contains the hard reference in the place where the identifier should be. For example, $ref = \$foo; $$ref = 10; print "$foo";

2. Placing an expression that returns a hard reference in curly brackets {} to replace the identifier. For example, $ref = \$foo; ${$ref} = 20; print "$foo";

3. If a hard 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 hard reference, then followed by the dereference operator: ->. For example, $ref = \@foo; $ref->[0] = 30; print "$foo[0]";

4. Of course, hard references can be nested. They can also be mixed with soft (symbolic) references. For example, $a = \$b; $b = \$c; $c = 40; print "$$$a"; Another example is: $a = \$b; $b = 'c'; $c = 50; print "$$$a";

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

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)

 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