chiark / gitweb /
Decrement $. when making concordance
[bible-kjv.git] / makeconc.pl
index 97a388db6525766294c7d70633176ed2aa1e2937..6ccc32d4392b0e35253e2ce3ee934722b3828b6a 100755 (executable)
@@ -18,6 +18,7 @@
 #  Received from Chris Eich, replaces "makeconcordance" script.
 #  Made use of stopwords conditional.
 ###############################################################################
+use IO::Handle
 
 # Putting . on PATH ensures that the bible program will be found.
 $ENV{'PATH'} =~ s/^:*/.:/;
@@ -40,7 +41,8 @@ if (open(STOP, "$ARGV[0]")) {
 # Generate plain text file, one "record" (e.g. bible verse) per line.
 # Fill %lines and $count tables, which are keyed by words.
 
-open(BIBLE, "$PROG -f gen1:1-rev99:99 |");
+open(BIBLE, "bible.rawtext");
+<BIBLE>; #discard the header line
 while (<BIBLE>) {
     s/^\S+\s+//;       # Cut off the record reference that starts each line.
     tr/A-Z/a-z/;       # Downcase.
@@ -50,10 +52,11 @@ while (<BIBLE>) {
        next if $stopword{$word};
        $count{$word}++;        # Move below next line to count per-line.
        next if $seenonthisline{$word}++;
-       $lines{$word} .= " " . $.;
+       #the header line discard still leaves $. 1 higher than we want
+       $lines{$word} .= " " . ($. - 1);
     }
 }
-close(BIBLE);
+die $! if BIBLE->error();
 
 # Create raw concordance, listing the lines where each word occurs.