> I attach it in case someone finds it useful.  If you have any ideas for
> improvements, they're welcome.  (Code improvements are even more welcome
> of course).

Too quick to hit send, sorry.

Yeah, the name of the script sucks.

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.
#!/usr/bin/perl -w

$pid = fork;
if ($pid == -1)
{
        print "woops ... $!";
        exit;
}
elsif ($pid != 0)
{
        exit;
}

use LWP::UserAgent;
$suffix = "";
$temp = `mktemp /tmp/patch.XXXXXX`;
chomp $temp;
open SAL, ">", $temp or die "$temp: $!";

$agent = LWP::UserAgent->new(keep_alive => 3);

while (<>)
{
        if (!defined $subject && /^Subject: \[COMMITTERS\] pgsql: (.*)/)
        {
                $subject = $1;
        } 
        elsif (m/^Modified/)
        {
                $suffix = "&f=H";
        }
        elsif (m/^Added/)
        {
                $suffix = "";
        }
        elsif (m,\((http://[^)]*)\)$,)
        {
                my $url = $1.$suffix;
                $res = $agent->get($url);
                print SAL $res->content;
        }
}

close SAL;
$subject =~ s/[ _'\/]/_/g;
rename $temp, sprintf ("/tmp/patch.%s.html", $subject);
---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Reply via email to