in reply to Re: Poor Person's Database
in thread Poor Person's Database

That was definitely a relevant article. I had never before noticed Search::Dict. That said, as soon as I looked at Search::Dict I found a bug and realized that the API should allow you to send in a comparison function rather than just assume that its two flags cover all cases people will see. But still it is a nice thing to know about.

Bonus marks to the next person who spots the bug. (Yeah, real text files won't tend to hit it, but still I think core modules should get this kind of thing right...)

Replies are listed 'Best First'.
Re: Re (tilly) 2: Poor Person's Database
by bikeNomad (Priest) on Jun 20, 2001 at 19:50 UTC
    Well, there's a bug where if the search is trying to return the last line in the file, and there's no newline, it'll chop the last character off. Did you mean something else?
      I actually meant something else.

      That specific bug is only going to bite if you had a search string that was the whole line and also was the last line in a file without a return. Similarly if $/ is set to a multi-line delimiter (eg \r\n because you are reading a DOS file in Linux) and the string you are looking for happens to include a tab right where a shorter entry has the \r, you may wind up with an incorrect location. (\r comes after \t, but no character should come before \t.)

      But look more carefully, there is another bug lurking in that code aside from the use of chop where chomp is a better fit.