home *** CD-ROM | disk | FTP | other *** search
- #!/usr/local/bin/perl
-
- opendir(DIR,".") || die "Cannot open .: $!";
-
- $flag = 0;
- file: while ($file = readdir(DIR)) {
- $new = $file . ".new";
- open(IN,"<$file") || die "Cannot open $file: $!";
- $article = "";
- while (<IN>) {
- if (/^$/) {
- if ($flag) {
- print "Alert: $file\n";
- } else {
- print "$file ok\n";
- }
- close(IN);
- next file;
- }
- if (/(.+)((Subject|Newsgroups): .+\n)/) {
- print "Fixing $file...";
- $flag = 1;
- open(OUT,">$new") || die "Cannot create $new: $!";
- print OUT $article;
- print OUT "From: $1\n$2";
- print(OUT $_) while (<IN>);
- close(IN);
- close(OUT);
- rename($new,$file) ||
- die "Cannot rename $new to $file: $!";
- print "ok\n";
- next file;
- }
- $article .= $_;
- }
- close(IN);
- }
- closedir(DIR);
-