|Think about Loose Coupling|
Programatically detecting a change in lettersby hacker (Priest)
|on Sep 03, 2007 at 19:12 UTC||Need Help??|
hacker has asked for the
wisdom of the Perl Monks concerning the following question:
I'm building a large dictionary of terms, MySQL-backed. Currently there are 3,223 entries in the database. I'm converting this into mobile format for handheld devices (constrained screen real-estate, limited "browser" capabilities, etc.)
Due to the limitations of the screen size, I've been asked to create named anchors that will go from the top of the list of terms, down to the next closest match of letters.
Each term displayed, would lack a <a name=".."> attribute unless its letter changed from the previous term's first two letters.
The first word to begin with "Be" would have an anchor that would put the user there when they selected it from the top of the page. It should look something like this:
It all works right now, except adding the named anchors at their respective "first instance" of words that begin with $letter . [aeiou];.
How can I detect the change in the words, as I'm outputting them one by one from my results set?
Here's a sample of the words from the live db. I've added indicators below, where anchors would logically be inserted:
Thanks, my fellow monks.