#!/usr/bin/perl
# Created by Jimmy O'Regan
use warnings;
use strict;
use WWW::Mechanize;

##### User-configurable variables #######################
my $password = 'PASSWORD';
my $url = 'URL';

# Set to non-zero to generate a troubleshooting log
my $debug = 0;
##### Past this point, There Be Dragons... ##############

my ( $mech, $content, %name ) = WWW::Mechanize -> new();
$mech -> get( $url );
$mech -> submit_form( fields => { adminpw => $password } );
$content = $mech -> content();

die "\u$&.\n" if $content =~ /no pending requests/;

for ( grep /^senderaction-/, split /[ \n"']/, $content ){
	unless ( exists $name{ $_ } ){
		print "Deleting $_\n";
		$name{ $_ } = 3;
	}
}

$mech -> submit_form( fields => \%name );

if ( $debug ){
	use Data::Dumper;
	open Fh, ">admreqrm.log" or die "Can't open log  $!\n";
	print Fh Dumper( %{ $mech->response() } );
}
