#!/usr/bin/perl -w ### sting ### ### Table Setup ### # CREATE TABLE subject_info # (id int not null auto_increment, plaintif varchar(100) not null, subject longtext not null, # date varchar(50) not null, primary key (id)); use warnings; use strict; use DBI; #file variables and flags# my $flag = '0'; my $spamcop_email = shift || 'c:\frodo\mail\spamcop_email.txt'; my $text_output = shift || 'c:\frodo\output\text_output.txt'; #regex parameters and variables# my $from = 'From: '; my $full_subject = 'Subject: '; my $date = 'Date: '; my @buffer = ('',''); #initialize arrays# open (SCEMAIL, "$spamcop_email") || die "Can't open $spamcop_email"; my @spamcop_email_array=; close (SCEMAIL); open (TEXTOUT, ">$text_output") || die "Can't open $text_output"; #loop and fill @buffer# foreach (@spamcop_email_array){ if(s/.*$from//){ $buffer[0] = $_; $flag = 0; } if(s/.*$full_subject//){ $buffer[1] = $_; $flag = 0; } if(s/.*$date//){ $buffer[2] = $_; $flag = 0; print TEXTOUT @buffer; } } close TEXTOUT; #DBI Connect and Insertion# my $dbh = DBI->connect("DBI:mysql:database=SpamCopBot; host=localhost", "amearse", "tttttt", {'RaiseError' => 1}); my $sth =$dbh->prepare("INSERT INTO subject_info (plaintif, subject, date) VALUES ('$buffer[0]', '$buffer[1]', '$buffer[2]')"); $sth->execute(); $sth->finish(); $dbh->disconnect();