Chapter 4
The only aspect of file naming that File::Spec doesn't treat is the constraints on 
the actual names themselves. The rule here is keep them short and simple. To be 
maximally portable, your filenames shouldn't be longer than 11 characters and 
should contain only one dot (.). Also, you can't count on a case sensitive file 
system, so having both test.pl and TEST.pl in the same directory is out. Spaces in 
filenames are generally verboten, as are punctuation characters aside from under 
scores and hyphens.
Portable modules should never contain hard coded paths. If you need to refer 
to an external file, you should provide a way for users of the module to specify it. Of 
course, when they do, they'll be using the filenaming conventions of their platforms, 
so use of File::Spec is necessary.
On Self Reliance
Think of a user's system as a strange and alien land you don't know where any 
thing is, you don't know who to ask for help, and you don't speak the language well 
enough to understand the user's reply if you did. In Perl terms, don't expect to be 
able to call external programs. Even if you could reliably locate the program you 
want, there's probably a version out there that produces output you aren't expecting. 
A classic example is the ps utility found on many UNIX systems. Every ps accom 
plishes the same basic task: displaying information about running processes. 
Unfortunately, every flavor of ps is different each takes different options and 
produces different output formats.
If you need a particular service in a portable module, you have two options 
code it yourself in pure Perl, or find a module that has it. The latter solution is def 
initely preferable portability problems are common ground shared by the entire 
CPAN community. The chances are quite good that the service you need is already 
available on CPAN.
Coding Around the Problem
One way to address portability is to build it into your module's design. A good example 
of this is in the way the File::Spec module works. File::Spec provides a standard API 
across all platforms using an object oriented inheritance strategy. File::Spec is con 
ceptually a virtual base class from which the concrete File::Spec subclasses inherit.
24
When you perform a use File::Spec, code inside File::Spec determines which 
24. Notice that I said  conceptually.  The implementation is actually the reverse File::Spec 
dynamically chooses one of the  subclasses  as its parent class. Perl OO is fantastic!
124






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