#!/usr/bin/perl

print <<EOD;

DiCT data file converter by David Proper (DrN)
Copyright 2001 Radical Computer Systems - All Rights Reserved.

This file will take your current DiCT dictionaries and convert them to
the new "format". What it actually does is convert the following
charactors: .:';"<>(){}[]\ to "coded triggers" used by DiCT v1.08 and up.
This prevents outputs like:

<LadySin>  script  = DiCT v1\.09 by Dr\. Nibble \(DrN\) -=:DrN:=-

And helps with the errors when searching the supplied alternate
dictinoaries. This convert does not have to be run on the alternate
dictionaries that come with DiCT v1.10 as they have allready been
converted.

Sorry for any inconvience this has cuased.

EOD

if (@ARGV > 0) {
        $fname = $ARGV[0];
} else {
          print "Calling Syntax: cntdict filename\n";
          exit;
         }

if(-f "$fname") {print "$fname exists. Converting.\n"} else {die "$fname don't exists. Aborting.\n"}

if (-f "bak.$fname") {system("rm bak.$fname");}
system("mv $fname bak.$fname");

open(DATA,"bak.$fname"); @data = <DATA>; close(DATA);

$datatot = @data;

$count = 0;


open(DATA,">$fname");
#print DATA "; DiCT v1.10 by Dr. Nibble \(DrN)\n";
#print DATA "; Copyright 2001 Radical Computer Systems\n";
#print DATA "script 992374260 DrN DiCT v1.10 by Dr. Nibble \(DrN)\n";
#print DATA "data 992374260 DrN The Acronym data from this file cane from the IRC section on Another Pointless Homepage. http://home.earthlink.net/~daproper/\n";

 while ($count < $datatot) {
                             $d = $data[$count];
                             chomp $d;

if (substr($d,0,1) eq ";") {print DATA "$d\n";} else {
                             ($w,$d,$e,$me) = split(/ /,$d,4);
                             $ac =~ s/ /_/g;
 $me=~s/\./!PD!/g;
 $me=~s/\:/!CO!/g;
 $me=~s/\'/!SQ!/g;
 $me=~s/\;/!QL!/g;
 $me=~s/\"/!QT!/g;
 $me=~s/\</!LT!/g;
 $me=~s/\>/!GT!/g;
 $me=~s/\(/!LP!/g;
 $me=~s/\)/!RP!/g;
 $me=~s/\{/!LB!/g;
 $me=~s/\}/!RB!/g;
 $me=~s/\[/!LF!/g;
 $me=~s/\]/!RF!/g;
 $me=~s/\\/!SL!/g;
                             print "#$count : $w = $me\n";
                             print DATA "$w $d $e $me\n";
                              }
                             ++$count;
                            }
close(DATA);

