;
close (INF);
$book = "";
$chap = "";
$vers = "";
$i = 10;
foreach $line (@data) {
if ($line =~ /^\#/) {
$line = "";
}
elsif ($line =~ /\d+[ONAona]\t\d+\t\d+\t(\d+)[ONAona]\t(\d+)\t(\d+)\t(.*\t)(\d+)\t(.+)/) {
$line = sprintf("%08d\t$1\t$2\t$3\t$4$6", $5);
}
elsif ($line =~ /(\d+)[ONAona]\t(\d+)\t(\d+)\t(.*\t)(\d+)\t(.+)/) {
$line = sprintf("%08d\t$1\t$2\t$3\t$4$6", $5);
}
elsif ($line =~ /(\d+)[ONAona]\t(\d+)\t(\d+)\t(.+)/) {
$line = sprintf("%08d\t$1\t$2\t$3\t\t$4", $i+10);
}
else {
print "Error on line: $line\n";
}
}
@data = sort @data;
#print @data;
foreach $line (@data) {
if ($line =~ /(\d+)\t(\d+)\t(\d+)\t(\d+)\t(.*\t)(.+)/) {
$ord = $1;
$nBook = $2;
$nChap = $3;
$vers = $4;
$sub = $5;
$text = $6;
$sub =~ s/\s*//g;
if ($sub ne "") {
$vers = "$vers!$sub";
}
$oBook = @OSISbook[$nBook-1];
if ($oBook eq "") {
print "Error unknown book: $book\n";
}
$text =~ s/\s*$//g;
if ($book ne $nBook) {
if ($book ne "") {
print OUTF "<\/chapter>\n";
$chap = "";
print OUTF "<\/div>\n";
}
print OUTF "\n";
}
if ($chap ne $nChap) {
if ($chap ne "") {
print OUTF "<\/chapter>\n";
}
print OUTF "\n";
}
print OUTF "$text<\/verse>\n";
$book = $nBook;
$chap = $nChap;
}
}
print OUTF "<\/chapter>\n";
print OUTF "<\/div>\n";
print OUTF "<\/osisText>\n";
print OUTF "<\/osis>\n";
close (OUTF);