CPAN Module Distributions
OS you're running under
25
and loads the appropriate File::Spec subclass, be it
File::Spec::Unix or File::Spec::OS2. This pattern, breaking out OS specific
implementations of a standard API, is an excellent one for portable code. One
major advantage is that it allows the code to start small supporting only a few
systems and grow in portability as additional subclasses are added.
Be Explicit
It's good to be portable; but if you can't, then you should be explicit about it. One
way to do this is to put code in your Makefile.PL that explicitly checks the OS at
installation. For example, if you know that your module can't possibly work under
Microsoft Windows, you could use code like this:
if ($^O eq MSWin32 ) {
die "Sorry, the Data::Counter module doesn t support Windows yet!\n";
}
This is much nicer than allowing a user to install your module and realize that it
doesn't work later. That said, this technique is hard to get right since you have to
either know all the $^O strings where your module will work or all the $^O strings
where it won't work. Neither piece of knowledge is easy to come by considering the
large number of possibilities.
Perl Version Independence
Another type of portability is compatibility with older versions of Perl. There are
many reasons why people don't upgrade their Perl, some good and some bad.
Ignore older versions of Perl at your own peril you never know when you'll end
up in a job where the hoary old sys admin insists that Perl 5.004 is as good today as
the day it was born!
Supporting older versions of Perl means avoiding new Perl features like the
plague. In particular, you'll need to watch out for using the newer syntactic
features of modern Perl our, use warnings, v strings (numbers of the form 1.2.3),
unquoted hash strings, unquoted strings on the left hand side of a =>, new fangled
regex extensions, and much more. Some of these will merely cause warnings
under old versions of Perl, but many will break the module unequivocally.
25. Using the $^O variable, which carries a short identifier specifying the OS. See the perlport
documentation for a complete list.
12
125
5
footer
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