2 ######################################
3 # Infobot Factoid Import/Export Tool #
4 ######################################
13 my $command = shift @ARGV;
14 my $filename = shift @ARGV;
15 if ($command eq '-d') {
17 } elsif ($command eq '-i') {
26 print " usage: $0 -d dbname\n";
27 print " prints out an ascii flat file of the database listed.\n";
28 print " dbname should be the basename of the db, e.g.\n";
29 print " $0 -d ../factoids-is > is.fact\n";
30 print " $0 -d ../factoids-are > are.fact\n";
32 print " $0 -i dbname\n";
33 print " imports an ascii flat file into the database listed.\n";
34 print " dbname should be the basename of the db, e.g.\n";
35 print " $0 -i ../factoids-is < chemicals.fact\n";
36 print " $0 -i ../factoids-is < is.fact\n";
37 print " $0 -i ../factoids-are < are.fact\n";
44 tie(%db, 'AnyDBM_File', shift, O_RDONLY, 0666);
45 while (my ($key, $val) = each %db) {
47 print "$key => $val\n";
53 tie(%db, 'AnyDBM_File', shift, O_WRONLY|O_CREAT, 0666);
56 unless (m/\s*(.+?)\s+=(?:is=|are=)?>\s+(.+?)\s*$/o) {
57 m/\s*(.+?)\s+(?:is|are)?\s+(.+?)\s*$/o;
59 if (length($1) and length($2)) {
60 if (defined($db{$1})) {
61 if (not $db{$1} =~ m/^(|.*\|)\Q$2\E(|.*\|)$/s) {