--- /dev/null
+#!/usr/bin /perl -w
+
+use DBI;
+my $dbh = DBI->connect('DBI:mysql:copyrighteous:localhost', 'mako')
+ or die "Cannot connect: " . $DBI::errstr;
+
+
+$sql = qq`SELECT comment_ID, comment_author from wp_comments`;
+$sth = $dbh->prepare($sql) or die "Cannot prepare: " . $dbh->errstr();
+$sth->execute() or die "Cannot execute: " . $sth->errstr();
+
+my @row;
+my @fields;
+while(@row = $sth->fetchrow_array()) {
+ my @record = @row;
+ push(@fields, \@record);
+}
+$sth->finish();
+
+# now process the fields
+
+my $new_username;
+my $comment_id;
+if (@fields != 0) {
+ foreach $line (@fields) {
+ # datestamp method
+ if (@$line[1] =~ /^.*\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} (.*)$/) {
+ $new_username = $1;
+ }
+ # just the ip address
+ elsif (@$line[1] =~ /^\d+\.\d+\.\d+\.\d+ (.*)$/) {
+ $new_username = $1;
+ } else {
+ next;
+ }
+
+ $comment_id = @$line[0];
+ #print "Old: ", @$line[1], "\n";
+ print "Updating: ", $comment_id, " ", $new_username, "\n";
+
+ $sql = qq`UPDATE wp_comments SET comment_author = "$new_username" WHERE comment_ID = $comment_id`;
+ $sth = $dbh->prepare($sql) or die "Cannot prepare: " .
+ $dbh->errstr();
+ $sth->execute() or die "Cannot execute: " . $sth->errstr();
+ $sth->finish();
+ #print "row $i - id is @$line[0], name is @$line[1]\n";
+ }
+}
+
+
+
+
+
+
+