]> git.donarmstrong.com Git - bin.git/commitdiff
add common subscriber
authorDon Armstrong <don@donarmstrong.com>
Fri, 17 Oct 2014 22:35:03 +0000 (15:35 -0700)
committerDon Armstrong <don@donarmstrong.com>
Fri, 17 Oct 2014 22:35:03 +0000 (15:35 -0700)
common_subscriber [new file with mode: 0755]

diff --git a/common_subscriber b/common_subscriber
new file mode 100755 (executable)
index 0000000..31b1d01
--- /dev/null
@@ -0,0 +1,97 @@
+#!/usr/bin/perl
+# common_subscriber given a set of Debian mailing lists, show the common subscribers
+# and is released under the terms of the GNU GPL version 3, or any
+# later version, at your option. See the file README and COPYING for
+# more information.
+# Copyright 2014 by Don Armstrong <don@donarmstrong.com>.
+
+
+use warnings;
+use strict;
+
+use Getopt::Long;
+use Pod::Usage;
+
+=head1 NAME
+
+common_subscriber -  given a set of Debian mailing lists, show the common subscribers
+
+=head1 SYNOPSIS
+
+common_subscriber [options]
+
+ Options:
+   --debug, -d debugging level (Default 0)
+   --help, -h display this help
+   --man, -m display manual
+
+=head1 OPTIONS
+
+=over
+
+=item B<--debug, -d>
+
+Debug verbosity. (Default 0)
+
+=item B<--help, -h>
+
+Display brief usage information.
+
+=item B<--man, -m>
+
+Display this manual.
+
+=back
+
+=head1 EXAMPLES
+
+common_subscriber
+
+=cut
+
+
+use vars qw($DEBUG);
+use IO::File;
+
+
+my %options = (debug           => 0,
+               help            => 0,
+               man             => 0,
+              );
+
+GetOptions(\%options,
+           'debug|d+','help|h|?','man|m');
+
+pod2usage() if $options{help};
+pod2usage({verbose=>2}) if $options{man};
+
+$DEBUG = $options{debug};
+
+my @USAGE_ERRORS;
+if (not @ARGV) {
+    push @USAGE_ERRORS,"You must give some mailing lists";
+}
+
+pod2usage(join("\n",@USAGE_ERRORS)) if @USAGE_ERRORS;
+
+
+my %subscribers;
+
+
+for my $list (@ARGV) {
+    my $fh = IO::File->new('/var/list/'.$list.'/dist','r') or
+        die "Unable to open /var/list/$list/dist for reading: $!";
+    while (<$fh>) {
+        chomp;
+        next unless /\@/;
+        $subscribers{$_}++;
+    }
+}
+
+for my $subscriber (sort keys %subscribers) {
+    print $subscriber."\n" if $subscribers{$subscriber} eq scalar @ARGV;
+}
+
+
+
+__END__