Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: tlug: http header parsing in perl



> I've been asked to write a Perl CGI to do the following:
> 
> 1) Be called by the web server in cases of a 403 or 404;
> 
> 2) Parse the http header and extract the customer's web directory (this
> is for virtual hosting customers), then check in that directory to
> see if the customer has a custom page for this situation present (these
> will have default titles, which I plan to call 403.html and 404.html);
> 
> 3) If the appropriate 403.html or 404.html page is not present in the
> customer's directory, serve up a default one from elsewhere.
> 
> OK, so I'm a Perl beginner (currently reading the Llama book) and step 2
> seems a bit beyond me.  I'm not sure just what form the http header
> will have and what I should read to find out;  Is the http header
> available in an environment variable or something, that the CGI can get
> it from there?  If so, what variable?  If not, how can I bring it into
> the script?
> 
> Also, there is a huge pile of stuff on CPAN, and I can't help thinking
> that somewhere in there is something that may already do this, but I'm
> not sure where to look.  If anybody has any Perl code that is already
> doing this (or soemthing similar), I'd love to get to take a look at it
> and see how it works, maybe borrow some or all of it, if that's OK.

You can sit and run through Perl books til your eyes turn blood red and
sleep is a forgotten concept. OR, you might look at www.developer.com or
some other repositories. There are scripts available to do just about
anything you want to do, and most are freeware; some are even GPL! I've
used quite a number of them, with my own adaptations to fit my needs.
Why reinvent the wheel?

You may need to update some of your Perl modules to use other scripts. If
first you install CPAN, then adding modules becomes very easy. Grab the
latest cpan-***.tar.gz file and untar it. Run perl Makefile.pl , make,
make test and install. Then run perl -MCPAN -e shell and you'll be in
the CPAN shell, which will let you access remote perl sites, install and
all sorts of cool things. It's an extremely handy little unit.

FWIW, I've found the Perl Cookbook to be useful, too, as there are lots
more examples of code for many kinds of tasks.

David
-------------------------------------------------------------------
Next Nomikai: TBD                    Tengu TokyoEkiMae 03-3275-3691
Next Technical Meeting: June 12 (Sat), 12  :30   place: Temple Univ.
-------------------------------------------------------------------
more info: http://www.tlug.gr.jp        Sponsor: Global Online Japan


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links