en_tw/ForPDF/FilesForUpdates/Output.to.csv.pl

33 lines
928 B
Perl

use 5.12.0;
my ($bk, $ch, $vs, $outputFile, $ulb, $tw, $dir, $ref) = ("", "", "", "/Users/Henry/Documents/git.Door43/en_tw/ForPDF/tWs.for.PDF.txt");
open LOG, ">:utf8", "/Users/Henry/Google Drive/WA/Test/out/log.log" or die;
open OUT, ">:utf8", $outputFile or die;
say OUT "Book,Chapter,Verse,Term,Dir,Ref";
open (my $file, "<:utf8", "/Users/Henry/Google Drive/WA/Test/out/output.dat") or die "/Users/Henry/Google Drive/WA/Test/out/output.dat:\n$!";
while (my $line = <$file>) {
chomp $line;
#say LOG $line;
if ($line =~ /^([^:]*) (\d+):(\d+):$/) {
($bk, $ch, $vs) = ($1, $2, $3);
say LOG $line;
} elsif ($line =~ /^\[([^\]]*)\]\(([^\)]*)\)$/) {
($ulb, $tw) = ($1, $2);
if ($tw =~ /^([^\/]*)\/([^\/]*)$/) {
($dir, $ref) = ($1, $2)
}
say OUT "$bk,$ch,$vs,\"$ulb\",$dir,$ref"
}
}
close $file;
close OUT;
close LOG;
system 'open -a /Applications/BBEdit.app $outputFile';
print "\n\tDone.";