VerseScrape 0.2
Got a comment from Matt Irvine over at TerraNova.org regarding VerseScrape 0.1 that read "uh oh! when the verse has parenthesis in it the verse scrape acts up! i guess there’s no real way around that."
For those of you unaware, I’ve combine a small screen-scraping Perl program with crontab to update my site with the International Bible Society’s Verse of the Day.
Yo Matt, good catch! Unfortuantely, I didn’t have time until 2am last night to work in a fix. Part of the problem was that after stripping away the Javascript, that is everything outside of parenthesis used to encapsulate the IBS Scripture of the Day using the document.write() function, I then used the remaining opening parenthesis character "(" to split the scripture reference away from the verse. This works great if there are no parenthetical remarks within the verse itself. Only, in dealing with the NIV, there are.
That smug snickering you hear are the "King James onlyists" knodding their heads right about now saying "see … told you so!"
Theological arguments aside, there are two approaches. One would be to implement Sermonizer::Scripturizer. And when I convert this into a module, I think I will. Or I can split the verse of the day up using the left parenthesis character "(", then peel off the last array member as my Bible reference, concatenting the rest into the Scripture verse. Sounds like a lot of work, but it’s actually only modifying one line of code, and adding two more lines of code.
The line we change is the one we use to split up the reference from the verse:
Instead of reading the results into 2 variables, we read the results of the split function into an array. We then then we use the pop function to remove the last array alement from the array, and use the join function to put the other array members back together:
$reference = pop(@verses);
$verse = join(”(”, @verses);
A bit kludgy, I’ll admit. But it gives me a chance to show you how many different ways there are to solve a problem. In fact, I suspect that some of you are thinking that very same thing as you read this. If you’re one of those, don’t be shy, throw down some code in the comment section so we can compare notes. There are no wrong answers, just so long as the verse of the day gets parsed correctly.
In the meantime, here’s your new version:










