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:
- 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.
- 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.
- 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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.