forked from hmw3/Tips_and_Hacks
44 lines
1.3 KiB
Perl
44 lines
1.3 KiB
Perl
use 5.12.0;
|
|
use Cwd;
|
|
|
|
my ($pwd, $slash) = (cwd(), "\\");
|
|
if ($^O eq "darwin" || $^O eq "linux") {$slash = "/"}
|
|
my $outDir = $pwd;
|
|
$outDir =~ s/\/([^\/]*)$//;
|
|
my ($originFile, $destinationFile) = ("$pwd${slash}Output${slash}tWs_for_PDF.txt", "$outDir${slash}tWs_for_xT_PDF.txt");
|
|
|
|
my ($bk, $ch, $vs, $ulb, $tw, $dir, $ref);
|
|
|
|
open LOG, ">:utf8", "$pwd${slash}Logs${slash}log.log" or die "$!:\n$pwd${slash}Logs${slash}log.log";
|
|
#say $destinationFile; die;
|
|
open OUT, ">:utf8", $destinationFile or die "$!:\n$destinationFile";
|
|
say OUT "Book,Chapter,Verse,Term,Dir,Ref";
|
|
|
|
open (my $file, "<:utf8", "$originFile") or die "$originFile:\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;
|
|
|
|
if ($^O eq "darwin") {system 'open -a /Applications/BBEdit.app $destinationFile'}
|
|
|
|
print "\n\tDone.\n\n\tBe sure to rename the new file for New or Old Testament.\n
|
|
!!! Important !!!\n
|
|
If this is for the Old Testament, make sure all instances of
|
|
josephnt are changed to josephot."; |