Chapter 3
But most users of the module will take the path of least resistance and import 
everything:
use BOA::Network;  # imports everything in @BOA::Network::EXPORT
The practice of exporting everything by default is known as namespace pollution
and it has a justifiably bad name for a number of reasons. If a group of modules are 
all exporting symbols by default, there's a good chance some of the symbols will 
conflict. Even worse, upgrading a module that exports everything by default can 
suddenly cause client code to fail by exporting a new symbol that causes a conflict.
Exporting everything by default also makes deciphering code more difficult. 
For example, imagine you've been given the task of debugging this code:
use Some::Module;
use Some::Other::Module;
use Yet::Another::Module;
some_call( ... );
If you're trying to figure out why some_call() is failing, you'll first have to 
search through each used module to determine where some_call() is being 
imported from. Contrast that to this case:
use Some::Module qw(some_call some_other_call);
use Some::Other::Module qw(foo bar);
use Yet::Another::Module qw(BIF BAZ);
some_call( ... );
Now it's immediately obvious that some_call() is being imported from Some::Module.
Fortunately the Exporter comes equipped with an alternative to @EXPORT that 
can be used to enforce the preferred explicit importing. Just change @EXPORT to 
@EXPORT_OK and modules will have to declare their imports explicitly. For example, 
if BOA::Network is changed to use @EXPORT_OK as follows:
package BOA::Network;
require Exporter;
@ISA = qw(Exporter);
@EXPORT_OK = qw(open_socket
                send_message
                receive_message
                close_socket
                start_server
                stop_server);
80






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