Newsgroups: gnu.emacs.gnus
From: John Hunter <jdhun...@nitace.bsd.uchicago.edu>
Date: 1999/07/16
Subject: Re: deleting existing duplicates
Kai> Do the dupes have a Gnus-Warning header? That could be used
Kai> to weeding them out. No; as far as I know these warnings are based on the Message ID which I have written a perl script which *works*. I use nnml so it is only It accepts a couple of options, '-h' gives the usage, '-v' is verbose, I include the script below in case any poor sucker has my problem. As usual, John Hunter --perl script begins here-- use strict; use Getopt::Std; getopts('ihv'); if ($opt_h || $#ARGV == -1) { } if ($opt_i) { $inquire_only = 1; } if ($opt_v || $opt_i) { $verbose = 1; } foreach $dir (@ARGV) { if (-d $dir) { $dir = path_strip_slash($dir) . "/"; print "\nChecking $dir\n" if $verbose; my (%email_lines, %email_sender, %email_recipient,$file,%match_file); foreach $file (dir_list_files($dir)) { while (<MAILFILE>) { close(MAILFILE); #remove the duplicates; clean up .overview unless ($inquire_only) { my $cleaned_overview_text = delete_lines_that_match("$dir.overview", \@delete_lines); } #foreach dir } sub print_help() { print <<"USAGETEXT"; Usage: $0 dir1 [dir2 dir3...] Options: -h print this help message -i inquire: print duplicate filenames only; change nothing. -v verbose; give all extra info Example: $0 -i Bugs } sub delete_lines_that_match { my ($filename, $array_of_regexps) = @_; my $output_text; open(INPUT,"<$filename") || die "can't open $filename\n";; while (<INPUT>) { my ($regexp, $line); $line = $_; my $match = 0; foreach $regexp (@$array_of_regexps) { if ($line =~ m/$regexp/) { $match = 1; } } #foreach rexep in array $output_text .= "$line" unless $match; } #while lines of input left close(INPUT); return $output_text; } #sub delete_lines_that_match sub dir_list_files { my @dir_files; my $dir = shift || '.'; opendir(DIR, "$dir"); my @full_list = readdir(DIR); foreach (@full_list) { #exclude . and .. push @dir_files, $_ unless m/\.\.?$/; } closedir(DIR); return @dir_files; } sub path_strip_slash { my $filename = shift; chop $filename if $filename =~ m#.*/$#; return $filename } --perl script ends here-- You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||