Chapter 4
Listing 4 10. Nonportable count_args.pl
#!/usr/bin/perl  w
use Data::Counter qw(count);
print count(@ARGV), "\n";
The solution to this problem is shown in Listing 4 11. ExtUtils::MakeMaker 
will execute any script ending in .PL at build time and use the output as the source 
for the script to install. The name of the file to be generated must be the name of 
the script preceding the .PL. This follows the pattern set by Makefile.PL generating 
Makefile. In the example shown, to generate count_args.pl, I created a file named 
count_args.pl.PL. This script uses the Config module to generate the correct perl
execution line for the start of the script file.
Listing 4 11. Portable count_args.pl.PL
use Config; # used to get at startperl
# open output script and make it executable
open OUT,">count_args.pl" or die "Can t create count_args.pl: $!";
chmod(0755, "count_args.pl");
# output perl startup line
print OUT $Config{startperl}, "  w \n";
# output the rest of the script
print OUT q{
  use Data::Counter;
  print Data::Counter::count(@ARGV), "\n";
};
This mechanism can be used to do more than just extract platform information 
from the Config module. Some overly clever module authors use .PL scripts in zany 
code generation schemes to gain flexibility and performance. I'll admit to being 
guilty of this charge, but I hesitate to suggest the practice to the sane!
Building the Distribution Archive
Building the distribution archive with ExtUtils::MakeMaker is as simple as running 
make dist (after running perl Makefile.PL, of course). This is the command that 
118






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