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.
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: