Slashdot Mirror


Writing CGI Applications with Perl

davorg contributes his review of Writing CGI Applications With Perl, writing "There are a very large number of Perl CGI books in the shops. Unfortunately the number of good Perl CGI books is far smaller. I'm happy to report that this book is one of them." Read on for the rest. Writing CGI Applications With Perl author Kevin Meltzer and Brent Michalski pages 500 publisher Addison Wesley, 2001 rating 9/10 reviewer Dave Cross ISBN 0-201-71014-5 summary Great Introduction To Writing CGI Programs in Perl

The problem, of course, with most Perl CGI books is that they are written by people who just don't know very much Perl. That's certainly not the case here. Both Kevin and Brent are well-respected members of the Perl community and they know what they are talking about when it comes to writing CGI programs in Perl.

Another common mistake in Perl CGI books is that the authors try to take people who know a bit of HTML and teach them programming, Perl and CGI all at the same time. The authors of this book realise that this approach is likely to lead to, at best, patchy understanding of any of these concepts so they aim there book at people who are already programmers and who have some knowledge of Perl. This means that they can concentrate of teaching the parts of Perl that are useful when writing CGI programs.

One corner that is often cut when discussing CGI programming is security. This is a very dangerous approach to take as a badly written CGI program can leave your web server open to attack from anyone on the Internet. That's not a mistake that is made here as the authors introduce security in chapter 2. Add to that the fact that the code examples all use -w, use strict and CGI.pm and the book is already head and shoulders above most of its competition.

Early chapters look at common CGI requirements such as file uploads and cookies. Each chapter is full of well written (and well-explained) sample code. The example of an access counter in chapter 6 even locks the file containing the current count - this is possibly a first in a Perl CGI book!

By the middle of the book we have already moved beyond simple CGI programming and are looking at mod_perl. This chapter covers both the "faux-CGI" Apache::Registry module and also writing complete mod_perl handlers.

In the second half of the book we start to look at some bigger examples. The authors present a web-based email system and even a shopping cart. In order to fit these examples into their respective chapters a couple of corners have been cut, but there's enough information there to enable anyone to write the complete systems.

Chapter 13 introduces the HTML::Mason module as a way to separate content from presentation. It's obvious that the author's are big fans of this module and this leads to my only real criticism of the book. At no point do they mention the fact that the same benefits can be gained from using any of half a dozen templating systems found on the CPAN. I would have been a lot happier if they had mentioned things like Text::Template, HTML::Template and the Template Toolkit before picking HTML::Mason as the system for their example.

There are then two more long chapters with examples of a document-management system and image-manipulation software. Once more, the code in these examples would serve as a great starting point for anyone wanting to implement something along these lines. The last chapter looks at XML and, in particular, the use of RSS files to provide data feeds to other web sites.

All in all this is a very useful book for someone wanting to write web-based applications using Perl. It's packed full of good advice and code that follows all of the best practices for writing CGI programs in Perl. This book won't teach you Perl, but if you've read Learning Perl or Elements of Programming with Perl then you'll find this book easy enough to follow.

You can purchase Writing CGI Applications with Perl from bn.com. Slashdot welcomes readers' book reviews -- to submit yours, read the book review guidelines, then hit the submission page.

18 of 249 comments (clear)

  1. FP by Anonymous Coward · · Score: -1, Offtopic

    So Mleh!

  2. perl by Anonymous Coward · · Score: -1, Offtopic

    i love perl

  3. Re:Perl is for girls by Lotus1618 · · Score: 0, Offtopic

    As a "girl" I take offense to that comment. Find a creative, non-sexist way to put down a programming language next tim.

  4. HURD is dead! by Anonymous Coward · · Score: -1, Offtopic

    I just read the news at kerneltrap -- GNU HURD is officially dead.

    According to lead developer Roland McGrath, Mach is the foundation of HURD, so it's future looks bleak.

    Long live linux!

  5. don't forget by Anonymous Coward · · Score: -1, Offtopic
    to read this report re-leased by the Institute de Linusville Inc., claiming how bad IT is when /./~VAlairy's.stock.markup.FraUD, is DOWn to touting stuff for the ill eagle kingdumb.

    no matter, fud IS dead. doN'T be hauled to the bottom with those payper liesense crooks, no matter what the cut of the pengwin suite they're wearin'.

  6. Re:Perl is for girls by an+Anonymous+Cowboy · · Score: -1, Offtopic

    A girl huh? Wanna hump with me?

  7. holy smoking flaimbait batman by Anonymous Coward · · Score: -1, Offtopic

    MOD PARENT DOWN! That's the bigest pile of flaimbait I have ever seen! Sheesh.

  8. MOD PARENT INTO OBLIVION by Anonymous Coward · · Score: -1, Offtopic

    Can someone please mod this troll into oblivion. Its impossible to read the article since it makes the page so wide

  9. Re:Perl is for girls by plasmasurfer · · Score: -1, Offtopic

    Good. That means I'm in the same league as all the other kick-ass female programmers I know. Stay away from Perl, moron.

    --
    To spot the expert, pick the one who predicts the job will take the longest and cost the most.
  10. THE HOLY BIBLE IS THE ONLY BOOK YOU REALLY NEED. by Subject+Line+Troll · · Score: -1, Offtopic
  11. Re:24 Hours by xanadu-xtroot.com · · Score: 0, Offtopic

    I think we need a new modifier.

    -2, Bright as a Shattered Bulb.

    or at least:

    -1, Zealot


    (and I'm a die-hard Linux user)

    --
    I'm not a prophet or a stone-age man,
    I'm just a mortal with potential of a super man.
  12. YOU COULD HAVE MADE THIS A SUBJECT LINE POST. COOL by Subject+Line+Troll · · Score: -1, Offtopic
  13. Re:Perl is for girls by suicidal · · Score: -1, Offtopic

    As a "Tim" I take offense to that comment. Find a creative, non-Tim-Bashing way to put down a retort next John.

  14. DID YOU MEAN "COLD FUSION'S FOR LARD ASSES?" by Subject+Line+Troll · · Score: -1, Offtopic
  15. IT IS MUCH MORE READABLE NOW. THANK YOU, KIND SIR by Subject+Line+Troll · · Score: -1, Offtopic
  16. You meant... by Anonymous Coward · · Score: -1, Offtopic

    kick not suck Right

  17. Completely off-topic by Anonymous Coward · · Score: -1, Offtopic

    Curious as to how long this will take...

    aspamtrap@argast.org

  18. What Larry's doing to Perl by Anonymous Coward · · Score: -1, Offtopic
    I've been using perl pretty much constantly since the Pink Camel, and believe me, Perl 5 is an extremely good language for quick scripting things. That's what it was designed for. Sure, you can do big projects in it, but it's not exactly ideal. Recently I've started using Ruby as well, and I intend to move my department over to it instead of wasting time with Perl 6.

    One of the goals of Perl 6 is to make non-trivial projects possible. That's good. The way it's being done is bad. Perl was once a lightweight, extremely flexible language. Now it's become a huge ugly monster. People wanted OO, so a nasty hack was bolted on top to allow some semblance of it. Now this nasty hack is being expanded. Sure, the code's different, but the basic form is the same. Kludge upon kludge upon kludge; I'd much rather have a nice, clean, pure language (and not one with loads of irritating whitespace thankyou very much).

    The same goes for the syntax. All the switching between $, @ and % is really irritating (ask a newbie how to get at the length of the keys array of a hash inside a hash, for example), and the changes proposed for 6 are just making this worse -- it seems that Larry, in his infinite wisdom, wants to prefix every data type with a different hard-to-type character. Perl was only designed for the three data types, and adding more is a mess.

    Perl 6 is a complete rewrite, but it keeps all the mess which has accumulated over the previous versions. This is not good. Sure, my const int $var = 27; may look neat (in the same way that, say, Pascal does), but $var isn't entirely constant, or entirely an integer, it's just a hack which makes it sort of behave like one. The whole thing is an exercise in pseudo-computer science masturbation with little real purpose except to please the managers who dislike the one thing that makes Perl special.

    On a similar note is regexes. I'm an avid fan of regular expressions simply because a nondeterministic finite automata is far more flexible than linear code. However, Larry must have been smoking that cheap $2 crack when he wrote this. Does he want Perl 6 to be flex or something?

    I won't be going on to use 6. It's a nice idea, but it's completely unnecessary. It won't make large projects any easier to manage (the language is still, at heart, an almighty hack -- an impressive one, but still a hack). It won't make OO any cleaner. It won't make development any faster. To put it bluntly, Perl scripts will still look less beautiful than our friend Mr Goatse. I'd prefer to use a language which has always been pure synthesis of science and engineering, not some half-baked imposter.

    Perl 6 will be nice, but I'm guessing it will be the end of Perl. It can't do what it wants to do whilst still being based upon a nasty mess. There are now other options, which provide all of Perl's power and none of the mess. Sorry, but *BSD, erm, Perl is dying.