Praethen has asked for the wisdom of the Perl Monks concerning the following question:

I'm fairly certain I'm doing this in the less than perfect way but at the moment I'm seeking a working solution, not necessarily the right way.

My site primarily uses SHTML (that is simple HTML files with the SSI Include element thrown in to insert template elements). Now I've added CGI form processing and would like to just output the success page.

I initially just ordered a $q->redirect($success_page) using CGI but in testing it's redirected me before completing the file upload.

More importantly, I don't seem to be handling errors as gracefully as I would like. I would like to be able to pull my template elements (header file, footer file, etc.) into the Perl CGI processing script to print when I have an error but I cannot do a simple 'open file, print it' dump because I use SSI includes in those files. I don't know how to do execute that the internal SSI in those pages (for example the footer file utilizes a SSI include of the site map).

In other words, I'd just like to have the Perl script completely handle the success or failure of the page and work like my SHTML files by being able to execute those files SSI.

Replies are listed 'Best First'.
Re: Print SHTML from inside Perl Script
by Anonymous Monk on Nov 10, 2011 at 09:28 UTC

    using CGI but in testing it's redirected me before completing the file upload.

    This sounds suspect -- perhaps you shouldn't print the header until you're finished processing the uploads

    being able to execute those files SSI.

    Lets see

    cpan://SSI
    needs mod_perl, Apache::SSI - Implement Server Side Includes in Perl
    bingo CGI::SSI - Use SSI from CGI scripts, a loose imitation of Apache's mod_include.
    negative review, no docs, ZM::SSI - SSI parser for CGI
    http://search.cpan.org/search?query=SSI&mode=all
    CGI::SHTML - a CGI module for parsing SSI

    I would stick with mod_include, and fix my cgi program to handle uploads properly

      Ooo. Brilliant CGI::SHTML, I only found CGI::SSI and that was not helpful for my plight.

      I did figure I must be printing something prior to the redirect or some other weirdness so I've been debugging that, hoping I can clean it up.

      Thanks.