[pm-h] generating and populating files using a systematic name scheme

Russell L. Harris rlharris at oplink.net
Fri Apr 18 19:18:25 PDT 2008


Over the weekend, I am attempting to use Perl for the task outlined
below.  

I have a copy of "Learning Perl" and "Perl Cookbook".  I likely shall
be doing things the hard way, so I welcome recommendations from anyone
who is interested.  

RLH

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

TASK:

Using an outline template and a set of text files, create a set of
outline files, one per chapter, for each book in the Bible.

The files are to be named according to the following scheme:

    outline-xx-yyy

in which xx is the sequential book number (01, 02, 03, ...) and yyy is
the sequential chapter number (001, 002, 003, ...).

Each outline file starts out as a copy of the outline template, into
which is copied the text of the corresponding chapter, the book name,
the sequential book number, the sequential chapter number, and the
filename.

DATA:

The Bible text is contained in a set of files named '01', '02', etc.,
in which each filename is the sequential book number ('01' for
Genesis, '02' for Exodus, etc.).  In each of these files, each
newline-delimited record corresponds to a single verse, and chapters
are delimited by the chapter number followed by a colon (:), as
follows:

    1:1 text of the first verse
    2 text of the second verse
    3 text of the third verse
    ...
    31 text of the last verse
    2:1 text of the first verse
    2 text of the second verse
    3 text of the third verse
    ...
    25 text of the last verse
    3:1 text of the first verse
    ...

ASSOCIATIONS FILE:

A file is used to associate the sequential book number, the book name,
and the number of chapters in the book.  In this file, each
newline-delimited record corresponds to a single book:

   01 Genesis 50
   02 Exodus 40
   ...

OUTLINE TEMPLATE:

In the outline template, several strings (each of which begins with an
equals sign (=)) act as placeholders for: the bookname, the sequential
book number, the sequential chapter number, the outline filename
(which is used in a URL), and the Bible text of the chapter:

    =bookname
    =book
    =chapter
    =filename
    =bibletext

PLAN OF ATTACK:

(1) Step record-by-record through the association file.  Using the
sequential book number and the number of chapters from each record,
append the filename 'outline-xx-yyy' to a copy of the outline
template.

(2) Step file-by-file through the outline files (approximately a
thousand in number) which were generated in step one:

    (2.1) Copy the outline filename into the '=filename' field of the
    outline file.

    (2.2) Decompose the outline filename in order to obtain the value
    to enter into the '=book' and '=chapter" fields of the file.

    (2.3) Use the 'book' value from the outline filename to index into
    the associations file, in order to obtain the string to enter into
    the '=bookname' field of the outline file.

    (2.4) Use the 'book' value from the outline filename to index into
    the Bible text directory to select the proper book file; then use
    the 'chapter' value from the outline filename to index into the
    book file to select the proper chapter; and finally copy the text
    of the chapter from the book file into the '=bibletext' field of
    the outline file.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


More information about the Houston mailing list