Annotation of db/prgsrc/chronicles.pl, revision 1.2

1.1       boris       1: #!/usr/bin/perl -w
                      2: 
                      3: =pod
                      4: 
                      5: =head1 NAME
                      6: 
                      7: chronicles.pl - check references between chronicles and db
                      8: 
                      9: =head1 SYNOPSIS
                     10: 
                     11: chronicles.pl I<chronicles_dir>
                     12: 
                     13: =head1 DESCRIPTION
                     14: 
                     15: Check the references between database and chronicles. 
                     16: 
                     17: 
                     18: =head1 BUGS
                     19: 
                     20: The database, user and password are hardcoded. 
                     21: 
                     22: =head1 AUTHOR
                     23: 
                     24: Boris Veytsman 
                     25: 
1.2     ! boris      26: =head1 $Id: chronicles.pl,v 1.1 2003/03/17 15:06:03 boris Exp $
1.1       boris      27: 
                     28: =cut
1.2     ! boris      29: 
        !            30:     use strict;
        !            31: use DBI;
        !            32: 
        !            33: 
        !            34: # Creating hash dbtochronicles;
        !            35: my($dbh) = DBI->connect("DBI:mysql:chgk", "piataev", "")
        !            36:     or die "Can't connect to DB chgk\n";
        !            37: my %dbtochronicles;
        !            38: my $sth=$dbh->prepare("SELECT FileName,URL from Tournaments where Type='þ' 
        !            39: and not isnull(URL)");
        !            40: $sth->execute;
        !            41: while (my ($name,$url) = $sth->fetchrow_array) {
        !            42:     $dbtochronicles{$name}=$url;
        !            43: }
        !            44: 
        !            45: 
        !            46: # Checking chronicles
        !            47: if (! -d $ARGV[0]) {
        !            48:     die "Cannot read $ARGV[0]";
        !            49: }
        !            50: chdir $ARGV[0] || die "Cannot chdir to $ARGV[0]: $!";
        !            51: opendir (DIR, ".") || die "Cannot open $ARGV[0]: $!";
        !            52: while (my $file=readdir(DIR)) {
        !            53:     if (-f $file && $file =~ /html$/) {
        !            54:        open (FILE, $file);
        !            55:        while (<FILE>) {
        !            56:            chomp;
        !            57:            if (/znatoki\/cgi-bin\/db.cgi\?tour=([^\"]*)\"/) {
        !            58:                my $name="$1.txt";
        !            59:                if (!exists($dbtochronicles{$name}) ||
        !            60:                    $dbtochronicles{$name} !~ /$file$/) {
        !            61:                    print "$file -> $name\n";
        !            62:                } else {
        !            63:                    delete($dbtochronicles{$name});
        !            64:                }
        !            65:            }
        !            66:        }
        !            67:        close FILE;
        !            68:     }
        !            69: }
        !            70: closedir DIR;
        !            71: foreach my $name (keys %dbtochronicles) {
        !            72:     print "$name -> $dbtochronicles{$name}\n";
        !            73: }
        !            74: 
        !            75: exit 0;
        !            76: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>