mirror of
https://github.com/perlbot/perlbuut
synced 2025-06-07 17:45:40 -04:00
27 lines
592 B
Perl
Executable file
27 lines
592 B
Perl
Executable file
#!/usr/bin/env perl
|
|
|
|
use strict;
|
|
use warnings;
|
|
use Data::Dumper;
|
|
use DBI;
|
|
use Text::Metaphone;
|
|
|
|
my $dbh = DBI->connect(
|
|
"dbi:SQLite:dbname=var/factoids.db",
|
|
"",
|
|
"",
|
|
{ RaiseError => 1, PrintError => 0 }
|
|
);
|
|
|
|
my $fsth = $dbh->prepare('SELECT * FROM factoid;');
|
|
my $isth = $dbh->prepare('UPDATE factoid SET metaphone = ? WHERE factoid_id = ?');
|
|
|
|
$fsth->execute();
|
|
|
|
while (my $row = $fsth->fetchrow_hashref()) {
|
|
my $orig_sub = $row->{original_subject};
|
|
|
|
my $metaphone = Metaphone($orig_sub);
|
|
print "$orig_sub => $metaphone\n";
|
|
$isth->execute($metaphone, $row->{factoid_id});
|
|
}
|