Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

statico (5018)

AOL IM: eisforian (Add Buddy, Send Message)


Co-author of Perl Testing: A Developer's Notebook []

Journal of statico (5018)

Thursday June 24, 2004
08:59 AM

kwiki fury! and some mailman list moderation fun...

[ #19467 ]


Yesterday was Kwiki fury on CPAN. The new Kwiki has been released, and If you've installed it, you know that the Kwiki only provides a very mininmal, bare-bones wiki. Everything is a plugin, and between Brian and I there are fourteen plugins on CPAN -- with more to come. Luckily, by now most of the Kwiki core stuff has propagated:

  • Kwiki (version 0.3x)

  • Kwiki::UserName

  • Kwiki::RecentChanges

  • Kwiki::Archive::Rcs

  • Kwiki::NewPage

  • Kwiki::Icons::Gnome

  • Kwiki::UserPreferences

  • Kwiki::Revisions

  • Kwiki::Search

Kwiki::Weather, Kwiki::Autoformat and Kwiki::VimMode are also up, Kwiki::PerlMode and Kwiki::PodMode are on the way from Brian.

I am also planning on marking Text::KwikiFormatish, which uses the old (Something I'm planning on implementing...)

Anyway, I usually paste some sort of handy code, so here it is. I hate having to open up a browser to delete spam sent to our moderated Mailman mailing list. That, combined with the prowess of Andy Lester and his WWW::Mechanize module, gives me this:

use strict;
use warnings;
# listmod - fast alternative to mailman list interface
# usage: listmod crew XXXXXXXX
die "usage: $0 <listname> <password>\n" unless @ARGV == 2;
my ($listname, $password) = @ARGV;
use CGI qw(unescape);
use WWW::Mechanize;
my $m = WWW::Mechanize->new();
use Term::ReadLine;
my $term = Term::ReadLine->new($0);
# submit the form, get the cookie, go to the list admin page
$m->set_visib le( $password );
# exit if nothing to do
print "There are no pending requests.\n" and exit
    if $m->content =~ /There are no pending requests/;
# select the first form and examine its contents
my $f = $m->current_form or die "Couldn't get first form!\n";
# get me the base form element for each email item
my @items = map {m/^.+?-(.+)/} grep {m/senderbanp/} $f->param
    or die "Couldn't get items in first form!\n";
# iterate through items, prompt user, commit actions
foreach my $item (@items) {
    # show item info
    my $sender = unescape($item);
    my ($subject) = [$f->find_input("senderbanp-$item")->value_names]->[1]
        =~ /Subject:\s+(.+?)\s+Size:/g;
    # prompt user
    my $choice = '';
    while ( $choice !~ /^[DAX]$/ ) {
        print "$sender\: '$subject'\n";
        $choice = uc $term->readline("Action: defer/accept/discard [dax]: ");
        print "\n\n";
    # set button
    $m->field("senderaction-$item" => {D=>0,A=>1,X=>3}->{$choice});
# submit actions

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.