Can you recommend a book for perl/cgi?

Grant McLean Grantm at
Wed Dec 4 19:58:48 CST 2002

Hi Doug

I've done the odd bit of web programming but when I started
there were no books.  There's a very low threshold to getting 
started.  For example, this is a fully functional CGI program:

#!/usr/local/bin/perl -w

my $now = localtime();

print <<EOF
Content-type: text/html

  <title>Hello World</title>
  <p>The time is now: $now</p>

Drop it in your web server's CGI-bin directory, make it 
executable, point your browser at it and you're away.

Some tips:

* Once you get on to processing forms and query strings,
  use to handle that side of things - don't try
  to roll your own parameter handling code.

* 'use CGI::Carp qw(fatalsToBrowser);' can save you a
  lot of stress when your script contains errors (of 
  course you'd save even more stress by not writing
  scripts with errors in the first place).

* provides functions for generating HTML - I have
  not found them to be useful and people smarter than me
  recommend against using them. (see also next point).

* Once you've gotten past the toy scripts, you'll want to
  separate content from logic (ie: unlike my script above,
  you should aim to have close to zero HTML in your code).
  I have used the Template Toolkit (from CPAN) and swear
  by it.  Other people like HTML::Template.

* If you're lucky enough to be using Apache, find out about
  mod_perl and use it.  O'Reilly's "Writing Apache Modules
  in Perl and C" by Doug MacEachern (Mr mod_perl) and Lincoln
  Stein (Mr is excellent.

* mod_perl will open up the possibility of other templating
  systems including Mason, embperl and Apache::ASP.

* If you're using XML, you might want to look at AxKit.

* Ask questions on this list.

* Visit PerlMonks (

* Have fun.


Grant McLean        BearingPoint Inc - formerly The Web Limited
+64 4 495 9026           Level 6, 20 Customhouse Quay, Box 1195
gmclean at                Wellington, New Zealand

> -----Original Message-----
> From: Doug Hendricks [mailto:Doug.Hendricks at]
> Sent: Thursday, December 05, 2002 2:30 PM
> To: wellington-pm-list at
> Subject: Can you recommend a book for perl/cgi?
> Hello, Wellington.
> I've been using Perl 5, both OO and non-OO, for a few years 
> now and am fairly confident.
> I know *nothing* about web programming -- I use Perl as a 
> general-purpose application language and for scripting.
> I may need to upskill to server-side web programming soon, 
> maybe mostly cgi stuff (not sure yet).
> What modern books can you recommend?
> I have a comp-sci/engineering background, so dense/academic 
> books are acceptable (but not required).
> I am already interested in "Writing CGI Applications with 
> Perl" by Meltzer and Michalski.  Is it good?
> Sincerely yours,
> Doug Hendricks

More information about the Wellington-pm mailing list