eXtropia: the open web technology company
Technology | Support | Tutorials | Development | About Us | Users | Contact Us
Resources
 ::   Tutorials
 ::   Presentations
Perl & CGI tutorials
 ::   Intro to Perl/CGI and HTML Forms
 ::   Intro to Windows Perl
 ::   Intro to Perl 5
 ::   Intro to Perl
 ::   Intro to Perl Taint mode
 ::   Sherlock Holmes and the Case of the Broken CGI Script
 ::   Writing COM Components in Perl

Java tutorials
 ::   Intro to Java
 ::   Cross Browser Java

Misc technical tutorials
 ::   Intro to The Web Application Development Environment
 ::   Introduction to XML
 ::   Intro to Web Design
 ::   Intro to Web Security
 ::   Databases for Web Developers
 ::   UNIX for Web Developers
 ::   Intro to Adobe Photoshop
 ::   Web Programming 101
 ::   Introduction to Microsoft DNA

Misc non-technical tutorials
 ::   Misc Technopreneurship Docs
 ::   What is a Webmaster?
 ::   What is the open source business model?
 ::   Technical writing
 ::   Small and mid-sized businesses on the Web

Offsite tutorials
 ::   ISAPI Perl Primer
 ::   Serving up web server basics
 ::   Introduction to Java (Parts 1 and 2) in Slovak

 

introduction to Perl 5 for web developers
Anonymous References  
Another way to create a reference involves creating a reference to an anonymous array, hash or subroutine. A reference to an anonymous array, hash or subroutine is a reference to a data structure that has no name of its own.

Why would you want to do this?

Well, perhaps you need the array only for a short moment in your program and do not want to clutter your name space on such an ephemeral object. With an anonymous reference, there is no name. The data gets read and written in Perl's memory space utilizing only the reference to the data structure mapped to an anonymous location in memory.

Whichever the case, to create a reference to an anonymous array, you use the square brackets ([]) such as in the following example in which we create a matrix of an anonymous array inside an anonymous array:

     my $arrayref = ['a', 'b', 'c',
                    ['1', '2','3']];

Notice that now you can get the value of "3" by using the following:

     print $arrayref->[3][2];

Similarly, you can create and access an anonymous hash using something like:

     my $hash_reference = {
     	'name'  => 'Gunther B',
        'phone' => '123-345-6789'
     };
     print $hash_reference->{'name'};
Previous | Next | Table of Contents