Stories
Slash Boxes
Comments
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 ]

pudge (1)

pudge
  (email not shown publicly)
http://pudge.net/
AOL IM: Crimethnk (Add Buddy, Send Message)

I run this joint, see?

Journal of pudge (1)

Friday April 20, 2001
07:00 PM

sf2slash

[ #67 ]
#!perl -w
use strict;
use LWP::Simple;
use Slash::DB;
use Slash::Utility;

createEnvironment('useperl');
my $url = 'http://sourceforge.net/developer/diary.php?diary_user=3660&diary_id=';
my @ids = qw(2477 2418 2356 2312 2261 2244 2152 2126 2082 1952 1936
    1857 1848 1777 1753 1738 1724 1643 1637 1542 1536 1527 1488
    1461 1427 1394 1384 1318 1297 1282 1272);

my $slashdb = getCurrentDB();

for (@ids) {
    my($date, $subj, $body);
    $_ = get($url . $_);

    s/\015//g;
    m|<TD colspan=2><TR><TD COLSPAN=2><B>Date:</B> (.+?)<BR>|s;
    $date = $1;
    m|<B>Subject:</B> (.+?)<P>|s;
    $subj = $1;
    m|<B>Body:</B><BR>(.+?)</TD></TR>|s;
    ($body = $1) =~ s/<br>\n<br>\n/\n\n/g;
    $body =~ s/<br>\n//g;

    for ($date, $subj, $body) {
        s/^\s+//;
        s/\s+$//;
    }

    $slashdb->sqlInsert('journals', {
        uid        => 1,
        description    => $subj,
        date        => $date,
        posttype    => 1,
    });

    my($id) = $slashdb->sqlSelect('LAST_INSERT_ID()');
    $slashdb->sqlInsert('journals_text', {
        id        => $id,
        article     => strip_plaintext($body),
    });

    print "Inserted $id\n";

}

__END__