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

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

by mr_mischief (Monsignor)
on Aug 15, 2007 at 02:07 UTC ( #632644=note: print w/replies, xml ) Need Help??

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

Your code makes a new section for every change in the second letter if the name. hacker wanted just to have sections at the vowels ( first letter . [aeiou] ).

Also, I'm not sure what's wrong with printing as the output comes, either, instead of building up an array.

Update: added code tags around character class.

Replies are listed 'Best First'.
Re^3: Programmatically building named anchors to warp to sections
by mreece (Friar) on Aug 15, 2007 at 03:57 UTC
    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.

      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.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2021-01-27 07:50 GMT
Find Nodes?
    Voting Booth?