Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re^3: Programmatically building named anchors to warp to sections

by mreece (Friar)
on Aug 15, 2007 at 03:57 UTC ( [id://632649]=note: print w/replies, xml ) Need Help??

in reply to Re^2: Programmatically building named anchors to warp to sections
in thread Programmatically building named anchors to warp to sections

if hacker really only wants the breaks only on vowels, it is an easy change. (if ($prefix =~ /[aeiou]$/ and $prefix ne $section) { ...?). but it begs the question, what is the first anchor? no anchors at all until you encounter a vowel in the second position? i was hoping to provide a hint to the right direction (substr), without providing a complete solution, because there are a lot of unknowns here!

the only issue with buffering versus printing is if you want to print the navigational anchor links before the content, without assuming that every anchor will actually exist. it may be best to first determine which anchors will actually be present, then print the navigational links, then the content.

Replies are listed 'Best First'.
Re^4: Programmatically building named anchors to warp to sections
by mr_mischief (Monsignor) on Aug 15, 2007 at 15:10 UTC
    Why wouldn't an anchor be present for every section? What does it hurt to have a "Bo" header if your first entry in the section starts with "Br"? It still effectively breaks the sections down

    Perhaps the vowels are not the best place to break the entries when one considers the actual frequency of words with [uvwxyz] as the second letter compared to those with [abcd], [efgh], [ijklmn], or [opqrst] as the second letter. There's nothing particularly wrong with those choices, though.

    Having uniform splitting of sections for each starting letter helps navigation quite a bit regardless of where the breaks are made or whether an entry actually starts with what the section header contains.
      if, for example, the phrase list begins "Art, Ant, Apple, Brown, Crab, Doom" then there would be no anchors until you get to Doom. if you don't have an aardvark or Aaron, you can end up with quite the list before you get to a word with a vowel in the second position.
        You're not understanding what I've written (or tried to write).

        Why would one not want to have the anchors simply because there is no term that exactly starts with those two letters?

        Your example just now assumes that words with different starting letters are on the same page, which is not at all the scenario proposed by the OP. I'll summarize again what's being discussed.
        1. hacker wants to have a page per letter of the alphabet.
        2. Entries on each page will be arranged alphabetically.
        3. Each page will be separated into sections based on the second letter of the entry.
        4. The choice was made to have these sections start at the vowels.
        Given the value of the same breaking points for the sections across pages regardless of the actual distribution of entries and the need to use extra memory to do otherwise, I see no reason not to have the labels present whether or not the data provides an exact substr(0,2) match to the label.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://632649]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-07-15 20:41 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.