#!/usr/bin/perl my @files=`ls -1 *.abw`; my @ident=`cat books`; foreach (@files){ my @lines; chop; open KW, ">>$_.keywords"; open USFM, ">>$_.usfm"; open VS, ">>$_.verse"; chomp(@lines=`cat $_`); @lines[1]="\\id @ident[$_-1] "; foreach (@lines) { s///; s/\ *[K|P]\ (.*?)<\/c><\/p>/\n\n\\c\ $1\ /g; s/<\/p>//g; s/.*?<\/c><\/p>//g; s/

(.*?)<\/p>/\n$1\ \\x\*/g; s/(.*?)<\/c>/\\v\ $1\ \ /g; s/\ <\/c>/\ \\x\ /g; s/(.*?)<\/c>/\ \\xk\ $1\ /g; s/(.*?)<\/c>/\ \\xt\ $2/g; s/^.*?style=\"Normal.*?$//g; s/^.*?style=\"En-tête.*?$//g; s///g; s/xid\=\".*?\"//g; s/^\ x\*//; s/<.*?>//g; s/(\\xt.*?)(\\xk)/$1\ \\x\*\ \\x\ $2/g; } $book = join ("", @lines); @lines = split("\n",$book); my $chapter, $verse =1; foreach (@lines) { if (/^\\c\ ([0-9]+)\ /) { $chapter=$1; } if (/^\\v\ ([0-9]+)\ /) { $verse=$1; } s/^\\v\ ([0-9]+)\ /$chapter.":".$verse."|"/e; s/\\x\*\ \\x\ /\\x\*\n$chapter:$verse\|\ \\x\ /g; s/\ (\\x\ +\\xk)\ +(.*?)(\\xt)/":".substr($2,0,4)."\| ".$1." ".$2.$3/eg; s/$/\n/; } @lines=split("\n",join("",@lines)); foreach (@lines) { s/\\c\ .*?$//; s/^\s*$//; s/\ :/:/; s/\s+\|/\|/; s/\|:/:/; s/\ +/\ /; s/$/\n/; } foreach (@lines) { if (/^[0-9]+:[0-9]+\|/) { print (VS $_); } elsif (/^[0-9]+:[0-9]+:/) { print (KW $_); } else {print (USFM $_);} } # print (USFM @lines); close USFM,VS,KW; }