Chapter 2
log file as well as the functions needed to operate on this state data. This is the 
basic definition of an object: state data and functions to operate on that state 
wrapped up in one data structure. The benefits of object orientation are increased 
flexibility and improved potential for code reuse.
...........................................................................................................................................................................................................................
References: A Brief Refresher
Perl supports object oriented programming through references. It's possible to do 
a lot of useful things with Perl without using a single reference. As a result you 
may be ready to learn object oriented Perl without having ever used a single ref 
erence. I'll give you a quick refresher on the topic, but if you're left with questions, 
I suggest you head for a good introductory book on Perl for details.
A reference is simply a variable that points to another variable. By points to, I 
mean that you can follow the link from a reference to the variable it references. 
This action of following a reference is known as dereferencing.
Here's a simple example that prints  Hello, New World  using a reference to a scalar:
$message = "Hello, New World.\n";
$ref = \$message;
print $$ref;
This example shows two important operations on references. First, a reference is 
created using the \ operator:
$ref = \$message;
After this line, $ref points to $message. You can see this in action by changing 
$message and observing that the new value is visible through $ref:
$message = "Goodbye, dear friend.";
print $$ref; # prints "Goodbye, dear friend."
Second, the reference is dereferenced using a second $ in front of the reference:
print $$ref;
You can create a reference to other types of variables but the result is always 
stored in a scalar. For example, this example prints  Hello, New World  using a 
reference to an array:
@array = ("Hello,", "New", "World");
$ref = \@array;
print join(" ", @$ref) . "\n";
36






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

web hosting perl

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Inexpensive Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Jsp Hosting Cheap Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved