blib/lib/MAB2/Record/uptodate.pl untested

filter: Statementstmt 0.0% 0 / 33 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 2 Podpod n/a totaltotal 0.0% 0 / 52 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/bin/perl -w
2  
3 use strict;
4 use LWP::Simple qw(mirror);
5  
6 =pod
7  
8 With this script we try to check if the files specifying the MAB2
9 standard have changed since the last download. If there are newer
10 files, they are downloaded and we call the external diff program to
11 see what has changed. Copying the changed file into the according
12 module is left to manual intervention.
13  
14 =cut
15  
16  
17 my $baseurl = qq{ftp://ftp.ddb.de/pub/mab/};
18  
19 my(%map) = qw(
20 segm000 Base
21 adressmab NULL
22 gkdmab gkd
23 lokalmab lokal
24 notatmab NULL
25 pndmab pnd
26 swdmab swd
27 titelmab titel
28 );
29  
30 my $all304 = 1;
31 for my $doc (keys %map) {
32 my $url = "$baseurl$doc.txt";
33 my $code = mirror $url, "$doc.txt" or die "Could not get $url";
34 warn "doc[$doc]code[$code]";
35 $all304 = 0 unless $code == 304;
36 }
37  
38 if ($all304) {
39 print "No document has changed since last download.\n";
40 exit;
41 }
42  
43 for my $doc (keys %map) {
44 next if $map{$doc} eq "NULL";
45 local $/;
46 open F, "$map{$doc}.pm" or die "Could not open $map{$doc}.pm: $!";
47 my $pm = <F>;
48 open F, "$doc.txt" or die "Could not open $doc.txt: $!";
49 my $txt = <F>;
50 close F;
51 $pm =~ s/^.*__DATA__\n//s;
52 if ($pm eq $txt) {
53 print "Document $doc unchanged\a\n";
54 sleep 2;
55 next;
56 }
57  
58 system "diff -u $map{$doc}.pm $doc.txt|less";
59 print "Enter RET\n";
60 my $foo = <>;
61 }