Finally, I found a designer that uses CGI... although he is printing the html manually...

Anyway.. I thought you might wanna look at this: http://alistapart.com/stories/perl/


He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.

Chady | http://chady.net/

Replies are listed 'Best First'.
Re: A List Apart: A Search Engine in Perl
by jryan (Vicar) on Feb 08, 2002 at 22:42 UTC

    by Joseph Ryan... I wonder who that is? ;)

    I agree that there are a number of style issues I took with a pinch of salt, just so the audience (most of whom have worked with php/asp but have never touched perl) could under stand more easily. Including the one with the regex that dws mentioned (I didn't want to have to explain \b as well, this was NOT intended as a tutorial to Perl), I'll come clean with the rest:

    1. Using an anonymous sub - Passing a reference to a sub is just so weird for a beginner; the idea of passing instructions seemed to make more sense.
    2. Undef'ing $/ - davorg mentioned that one to me. He suggested that I should have local'ed it in the sub instead. He is right, of course. At the time, I was concerned that the "Slurp" trick (do{local $/; $string=<FILE>}) would have been too complicated, so I resorted to undefing.
    3. Confession time - I lie at one point. I call stat in void context to explain where the file-test operators come from. I do have an excuse. I remember the first time that I saw them - I was thrown for a loop. There is really nothing comparable in any other language, and they can't really be classifed as anything. So, I said that they can be used after the file is stat'd. Crucify me if you need to :(

    Also, I intentionally did NOT use CGI.pm's html functions (with the exception of start_html and end_html, and stated a caveat about using them). The audience that this is aimed for writes w3 valid xhtml for a living. I would not need to explain xhtml to them, but I would need to explain the HTML functions. Where is the benefit in using them?

    I would like to point out that this is simply for demonstrative purposes. I even state that in the article. The whole goal was to get php/asp developers really excited that they can do so much with so little code in perl that they would want to investigate perl on their own. Besides, if they really just want a search engine, there is a link to nms-cgi in my bio ;)

    So, does the article do overall good, or overall evil? Please tell me what you think.

      No, this article is NOT an 'evil doer'. :)

      In fact, years ago, it was articles similar to this that brought me inside the Perl(y) gates. (There's something odd about that phrase...)

      There's just no substitute for making Perl seem approachable for whoever the audience is.

      It's akin to another thread Camel Fishing that looks at many of the 'human issues' of 'getting into Perl'.

      Not only is there MTOWTDI in Perl, there is also MTOWT discuss and promote it.

      Thumbs up.

Re: A List Apart: A Search Engine in Perl
by dws (Chancellor) on Feb 08, 2002 at 21:50 UTC
    Anyway.. I thought you might wanna look at this...

    For a quick intro to how to write a naive, search-everything-all-the-time search facility, that isn't a bad article. It might be enough to interest some readers into pursuing Perl.

    The article does have a few problems, though. One is that   $string =~ /\Q$query\E/i is going to lead to false hits without any indication (such as hit highlighting) about why a page that contained "basement" matched when I went looking for "base".