[sword-devel] Feature Complete Perl Interface

John Keiser sword-devel@crosswire.org
19 Jul 2001 21:57:20 -0400


--=-OkNQmayqhlI1beQ5A9BK
Content-Type: text/plain

I have upgraded the interface with the ability to list books, chapters,
verses, and the ability to search.  Pretty much everything you need is
in here now.  Time to make a nice CGI interface!  Should be a cinch with
this.

I would love comments on the interface, if people can think of ways to
do it better.  One thing I'm planning on is having each module detect
which books it actually has installed by checking to see if the first
verse of the book exists or not.  Some modules like ISV don't have
everything.

Interface attached.  Pound away!


INSTALLATION
------------
1. tar xzvf Sword-0.02.tar.gz
2. cd Sword-0.02
3. perl Makefile.PL
4. make
5. make install


USAGE
-----

OK, now you can go through the Bible with the interface three ways:

1. go directly to verses by name and then step through the Bible up and
down

This prints out everything from I John 2:3 to the end of the Bible:

use Sword;
my $mod = new Sword::Module("KJV");
my $vi = $mod->get_iterator("I John 2:3");
do {
    print $vi->get_key(), " : ", $vi->get_verse(), "\n";
} while($vi->next());
# $vi->prev() would go to the beginning of the Bible backwards


2. Browse by book, chapter and verse

This prints out the first verse of every book in the Bible:

use Sword;
my $mod = new Sword::Module("KJV");
my $vi = $mod->get_iterator();
foreach my $book ($mod->get_books()) {
    $vi->set_book($book);
    $vi->set_chapter_num(1);
    $vi->set_verse_num(1);
    print $vi->get_key(), " : ", $vi->get_verse(), "\n";
    # You can use get_book, get_chapter_num
}


3. Search for verses

And of course you can search!  This gets everything in the KJV with the
word "sword" in it:

use Sword;
my $mod = new Sword::Module("KJV");
foreach my $result ($mod->search("sword")) {
    print "$result->[0] : $result->[1]\n";
}


--John Keiser


--=-OkNQmayqhlI1beQ5A9BK
Content-Type: application/x-gzip
Content-Disposition: attachment; filename=Sword-0.02.tar.gz
Content-ID: 995594223.2348.0.camel@cy209696-a
Content-Transfer-Encoding: base64

H4sICFOPVzsCA1N3b3JkLTAuMDIudGFyAOw8a1fiyLb9lfyKamQNoRsQ8DWDo3dopFumFb2CTs9y
PJwYCskICZMEaKeX57fcn3r33lWVVHio8/KsO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