Chapter 2
To support this usage, BOA::Logger would need to be modified to initialize a 
$VERSION package variable:
package BOA::Logger;
$VERSION = 1.1;
Since these features are provided as method calls in a parent class, child 
classes can override them and provide their own implementations. This enables 
classes to lie to the rest of the world about their inheritance, capabilities, and even 
version. In Perl, things are not always as they appear.
Overloaded Modules
Object oriented programming can be cumbersome. Everything is a method call, 
and sooner or later all your method calls start to look the same. Overloading your 
modules provides a way to simplify code that uses your module. It allows you to 
express code like the following:
$foo >add(10);
print "My favorite cafe is " . $cafe >name() . "\n";
in a more natural way:
$foo += 10;
print "My favorite cafe is $cafe\n";
Overloading enables your objects to work with Perl's existing math and 
string operators. When a Perl operator is used with an object of an overloaded 
class, a method is called. You specify which operators you are overloading and 
which methods to call using the overload pragma.
16
package My::Adder;
use overload  +  => "add",
                 => \&subtract;
The overload pragma takes a list of key value pairs as an argument. The keys are 
symbols representing the various operators available for overloading. The values 
specify the method to call when the operator is used; this can be expressed as a 
16. A pragma is loosely defined as a module that functions as a compiler directive; it changes the 
way Perl compiles the code that follows. The pragmas that come with Perl all have lowercase 
names.
48






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