75 lines
1.9 KiB
Perl
75 lines
1.9 KiB
Perl
# Combines most recent ULB with KJV with codes.
|
|
|
|
use 5.12.0;
|
|
use Cwd;
|
|
use FindBin '$Bin';
|
|
|
|
my ($pwd, $d) = ($Bin, "\\");
|
|
if ($^O eq "darwin" || $^O eq "linux") {$d = "/"}
|
|
|
|
# /Users/Henry/Documents/git.Door43/en_tw/ForPDF/FilesForUpdates/CombineULBandNASBwithCodes.pl
|
|
my ($ulb, $nasb) = ("$Bin${d}Temp${d}ULB_text.txt", "$Bin${d}Data${d}NASB_Strongs.txt");
|
|
my ($ref, $val, $textEditor);
|
|
my (%codes);
|
|
|
|
open LOG, ">:utf8", "$Bin${d}Logs${d}log.log" or die;
|
|
open OUT, ">:utf8", "$Bin${d}Temp${d}ULB_NASB_Strongs.txt" or die;
|
|
|
|
#say "\$pwd: $pwd${d}User${d}User_defaults.txt";
|
|
#say " /media/henry/92C6F7E3C6F7C58F/Users/henry/WA_Repo/Tips_and_Hacks/MAST_tW_PDF_Updater/FilesForUpdates/User/User_defaults.txt";
|
|
|
|
chdir $Bin;
|
|
|
|
my ($udf) = "User_defaults.windows.txt";
|
|
if ($^O eq "linux") {$udf = "User_defaults.linux.txt"}
|
|
elsif ($^O eq "darwin") {$udf = "User_defaults.mac.txt"}
|
|
|
|
open (my $defaults, "<:utf8", "$Bin${d}User${d}$udf") or die "$Bin${d}User${d}$udf:\n$!";
|
|
|
|
while (my $thisLine = <$defaults>) {
|
|
chomp $thisLine;
|
|
if ($thisLine =~ /^Text editor: (.*)$/) {
|
|
#say LOG "$thisLine";
|
|
$textEditor = $1;
|
|
}
|
|
}
|
|
|
|
#say "\$textEditor: $textEditor";
|
|
die "No text editor found" if $textEditor eq "";
|
|
|
|
close $defaults;
|
|
|
|
open (my $file, "<:utf8", "$nasb") or die "$nasb:\n$!";
|
|
|
|
while (my $line = <$file>) {
|
|
chomp $line;
|
|
if ($line =~ /^([^\t]*)\t(.*)$/) {
|
|
($ref, $val) = ($1, $2);
|
|
$ref =~ s/^Song of Solomon/Song of Songs/;
|
|
$codes{$ref} = $val;
|
|
}
|
|
}
|
|
|
|
|
|
open ($file, "<:utf8", "$ulb") or die "$ulb:\n$!";
|
|
|
|
while (my $line = <$file>) {
|
|
chomp $line;
|
|
#say LOG $line;
|
|
if ($line =~ /^([^\t]*)\t(.*)$/) {
|
|
($ref, $val) = ($1, $2);
|
|
if (exists $codes{$ref}) {
|
|
say OUT "$ref\t$val\n $codes{$ref}"
|
|
}
|
|
}
|
|
}
|
|
|
|
close OUT;
|
|
# say "Calling \$textEditor $textEditor";
|
|
if ($^O eq "darwin") {
|
|
system ("open -a $textEditor $Bin${d}Temp${d}ULB_NASB_Strongs.txt");
|
|
}
|
|
|
|
close LOG;
|
|
|
|
print "\n\tDone\n\n\tOutput is in $Bin${d}Temp${d}ULB_NASB_Strongs.txt\n\n"; |