WWW/Mechanize/makeppd.pl untested

filter: Statementstmt 0.0% 0 / 48 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 68 CC 2 SCAR 12.8
CC
2
Cov
0%
findNewest
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 3.6
1 #makeppd.pl 2.0
2 use FileHandle;
3 use File::DosGlob qw(bsd_glob);
4 #use Win32::FileOp;
5 use Config;
6  
7 $make=$Config{make};
8  
9 my $has_xs = 0;
10  
11 system('perl Makefile.PL');
12 system($make) and die "Failed to make!\n";
13  
14 system($make, 'dist'); # this creates the ordinary distribution
15 # I need the archive to find the version number!
16 # If you comment this out, always copy the archive to current directory.
17  
18 # this part of code finds the latest distribution, I don't have time to
19 # explore how to find the version number
20 @archives = grep {!/-PPM\.tar\.gz$/i} bsd_glob('*.tar.gz');
21 $archive = findNewest (@archives);
22  
23 ($name = $archive) =~ s/\.tar\.gz$//;
24 ($module = $name) =~ s/-[\d.]+$//;
25 ($file = $module) =~ s/^.*-(.*?)$/$1/;
26  
27 $ppd = $module.".ppd";
28 $module =~ s/-/\\/g;
29  
30 print "Module name : $file\n";
31 print "Newest archive is $archive\n";
32  
33 system('perl','Makefile.PL', "BINARY_LOCATION=$name-PPM.tar.gz");
34 #system($make, 'ppd');
35 # you may do something like
36 system($make, 'ppd', "BINARY_LOCATION=$name-PPM.tar.gz");
37 # if you do not apply my patch to ExtUtils\MM_Unix.pm
38  
39 system("tar cvf $name-PPM.tar blib");
40 system("gzip --best $name-PPM.tar");
41  
42 #Delete qw(blib pod2html-dircache pod2html-itemcache pm_to_blib pod2htmd.x~~ pod2htmi.x~~);
43  
44 if (! $has_xs) {
45 open $PPD, "<$ppd" or die "Can't open the $ppd file: $!\n";
46 open $NEWPPD, ">$ppd.tmp" or die "Can't create the $ppd.tmp file: $!\n";
47 while (<$PPD>) {
48 next if (/<ARCHITECTURE/);
49 print $NEWPPD $_;
50 }
51 close $PPD; close $NEWPPD;
52 unlink $ppd;
53 rename $ppd.'.tmp' => $ppd;
54 }
55  
56 exit;
57  
58 #==================
59  
60 sub findNewest {
61 my $maxitem;
62 my $maxver = pack('C4',0,0,0,0);
63 foreach my $item (@_) {
64 $item =~ /-(\d+)\.(\d+)\.(?:(\d+)\.(?:(\d+)\.)?)?tar\.gz/;
65 my $ver = pack('C4',$1,$2,$3,$4);
66  
67 if ($ver gt $maxver) {
68 $maxver = $ver;
69 $maxitem = $item;
70 }
71 }
72 return $maxitem;
73 }
74