All pastes #825298 Raw Edit

Mine

public text v1 · immutable
#825298 ·published 2007-12-20 13:58 UTC
rendered paste body
#!/usr/bin/perl -w
use strict;
use warnings "all";
use DBI;
##! /usr/bin/perl
my $dbh = DBI->connect("DBI:Pg:dbname=dict","dict","passwd");
open(IN, "< no_no.txt");
while(my $line = <IN>){
$line=~s/\e.+?m//g; #this should get them :(
my $par; my $brk;
chomp($line);
#my $line = "testamente: (subst.) [arverett] last will (and testament), testament, will";
$line=~s/'/\\'/g;
$line=~s/^(.*): //; my $word = $1;
my $defn = $line;
$line=~s/^(\(.*\)) //; $par = $1;
$line=~s/^(\[.*\]) //; $brk = $1;
my $sql = "insert into dict (word,defn";
my $end = "(\"$word\",\"$defn\"";
if($par ne ""){ $sql .= ",par"; $end .= ",\"$par\""; }
if($brk ne ""){ $sql .= ",brk"; $end .= ",\"$brk\""; }
$sql .= ") VALUES "; $end .= ")"; $sql .= $end;
#print $sql . "\n";
$dbh->do($sql);
}