#!/usr/local/bin/perl # Try to perform the stantard-archive-name to msdos-name conversion # for our FAQ collection. # Original copies should be in the original directory hierarchy. # # They can be downloaded from ftp.sunet.se /pub/usenet/news.answers/ # ## Determine some time constants @months = ( "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ); @mons = ( "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec" ); ($sec,$min,$hour,$mday,$Mon,$Year,$wday,$yday,$isdst) = localtime; ## Filenames $DOSFAQ_DIR = "/ftp-service/ftp/pub/msdos/programming/faq"; $MYFAQ_DIR = "out_faq"; $DIR_INDEX = $DOSFAQ_DIR . "/00index.txt"; $TARGET = $MYFAQ_DIR . "/00index.txt"; print "found $OLDINDEX\n\n"; print "Writing to $TARGET\n\n"; # Get the FAQ file descriptions ... open (M, "<$DIR_INDEX"); print "Reading FAQ index\n"; while () { if (/\s*(\S+)(.*)/) { $FILESPEC{$1} = $_; print "\t$1:$FILESPEC{$1}"; # any TABs inclusive } } open (foo, "ls $DOSFAQ_DIR |") || die "Can't open directory $DOSFAQ_DIR"; open (OF, ">$TARGET"); open (ERR, ">00missing"); line: while () { chop; if (/^\s*$/) { next line; } # Empty line if (/^00/|/\/00/|/00index/) { next line; } # Index file $file = $_; # Scan the FAQ file for it's original Archive-name and Version $cnt = 0; $prev=""; open (M, "<$DOSFAQ_DIR/$file"); print "\nChecking '$file'\n"; while () { chop; if (/^\s*Archive-name:\s+(\S+)\[\d+\-\d+\]/) { for ($part = $2; $part <= $3; ++$part) { $ORIGNAME{$file} .= " " . $1 . "$part"; ++$cnt; } } elsif (/^\s*Archive-name:\s+(\S+)\*/) { $ORIGNAME{$file} .= " " . $1 . "?" . " " . $1 . "0?"; $ORIGNAME{$file} .= " " . $1 . "1?" . " " . $1 . "2?"; $cnt = 9; } elsif (/^\s*Archive-name:\s+(\S+)/) { $ORIGNAME{$file} .= " " . $1; ++$cnt; } elsif (/^\s*Version:\s+(\.+)/|/^\s*Issue:\s+(\.+)/) { $VERSION{$file} = $1; } } if (!$prev) { $prev = $1; } elsif ($prev ne $1) { print "*** Alien part '$1' called from '$file' ***\n"; print ERR "*** Alien part '$1' called from '$file' ***\n"; } print "$file $VERSION{$file}\n"; if (!$cnt) { print "*** No origname found for '$file' ***\n"; print ERR "No origname found for '$file'\n"; } elsif ($cnt == 1) { print "cp $ORIGNAME{$file} $MYFAQ_DIR/$file\n"; system "cp $ORIGNAME{$file} $MYFAQ_DIR/$file"; } else { print "cat $ORIGNAME{$file} > $MYFAQ_DIR/$file\n"; system "cat $ORIGNAME{$file} > $MYFAQ_DIR/$file"; } if ($FILESPEC{$file}) { printf OF ("$FILESPEC{$file}"); } else { printf "*** Description for '$file' not found. ***\n"; printf ERR "*** Description for '$file' not found. ***\n"; } next line; } close OF; close ERR; print "done.\n"; #chmod 664 00new.tmp; #mv 00new.tmp $monfile;