Re: HTML/Perl Question

by Paul Clark <pclark(at)gate.net>

 Date:  Tue, 30 Nov 1999 13:50:07 -0500
 To:  hwg-basics(at)mail.hwg.org
 Cc:  "jamin brazil" <jamin(at)macroinc.com>
 In-Reply-To: 
  todo: View Thread, Original
-------------------------------------------------------------------
Jamin,

The easiest way is to use server side includes:

<!-- #exec cgi="/survey/survey.cgi" -->

which will include the output of your cgi script into the html document at 
the point of the server side include.

If you don't have the ability to use server side includes on your server 
you can use do something like the following:

place a comment such as <!-- include cgi output --> into your html 
document, then in your cgi script open the html document, process it line 
by line outputting the html and when it hits the comment line <!-- include 
cgi output --> have it output the survey results, then continue outputing 
the html document.

open(FILE, "</path/to/myfile.html") || die "Could not open input file 
($!)\n\n";
while (<FILE>) {
    chomp();
    if ($_ =~ m%<!-- include cgi output -->%i) {
       do survey procedures currently in your cgi script
    }
    else {
       print $_ . "\n";
    }
}
close(FILE) || die "Could not close input file ($!)\n\n";

I hope this helps a bit.

Paul

 > At 07:02 AM 11/30/99 -0700, you wrote:
 > Date: Sun, 28 Nov 1999 19:09:29 -0800
 > From: "jamin brazil" <jamin(at)macroinc.com>
 > Subject: HTML/Perl Question
 >
 > I am trying to incorporate a survey (the perl code for the survey is working
 > fine) into my home page.  In order for me to easily do this I would like to
 > just call the cgi from within my html document sorta like I do my style
 > sheet:
 >
 > <link rel='stylesheet' type='text/css' href='scripts/style.css'>
 >
 > or like my JS scripts:
 >
 > <script language="JavaScript"
 > src='http://www.macroinc.com/scripts/somescript.js'></script>
 >
 > At any rate...I am sick and can't seem to come to an easy solution...if
 > anyone has some insight I would appriciate the help.
 >
 > My HTML document:
 > http://www.best.com/~webcon/index.html
 >
 > My CGI:
 > http://www.best.com/~webcon/survey/survey.cgi
 >
 > Thanks for the help,
 > Jamin


-------------------------------------------------------------------
Paul Clark
pclark(at)gate.net

Art History / Graphic Design / HTML / JS / Perl
-------------------------------------------------------------------

HTML: hwg-basics mailing list archives, maintained by Webmasters @ IWA