#!/usr/bin/perl # # 2002 Michael Bunk # only sgml tei! $hdfile = shift @ARGV; if ($hdfile eq "") { print stderr "Usage: hd2dict \n"; print stderr " To convert headword definition dict files to TEI format. Output\n"; print stderr " is on stdout.\n"; die; } die "Can't find file \"$hdfile\"" unless -f $hdfile; open(HDHANDLE, "<".$hdfile); while () { push(@zeilen,$_); } print " \]>\n"; print "<\?xml version='1\.0' encoding='ISO-8859-1'>\n"; print "\n\n\n".$hdfile."\n"; print " converted withhd2tei\.pl\n"; print " \n

freedict\.de\n"; # Statement aus Quelldatei uebernehmen (Zeilen vor dem ersten %h) for(@zeilen) { if (/^%h/) {last;}# Schleife abbrechen print $_; } print "

\n

".$hdfile."

\n"; print "\n"; $openentry = 0; for(@zeilen) { chop; if(/^%h/) { if ($openentry == 1) { print "\n"; $openentry = 0; } print "
".substr($_,3)."
\n "; next; }; if(/^%d/) { $openentry = 1; next; } if ($openentry == 1) { print $_;} else { print stderr "Unsinn: ".$_."\n";} } print "
\n"; close(HDHANDLE);