in reply to Re: Re: Append script output to complex block of html and script
in thread Append script output to complex block of html and script

The code below does as you ask. It opens an existing html file, prints it and then runs your script.

use strict; use warnings; open(FH,"<./test.html") || die "couldn't open file $!\n"; my @html=<FH>; close(FH); print @html; print " my script stuff<P>\n"; print '</body>';
As monkfish suggests a server side include may also do what you want.

You would put the following line inside your html document

<!--#exec cgi="/cgi-bin/yourscript.pl" -->

Some random personal SSI thoughts:

  1. Microsoft IIS is more forgiving of syntax sloppiness. For example you can have a space between the -- and the # This can cause problems when you switch to apache.

  2. Your server has to have SSI enabled and has to allow exec commands. Allowing any user to execute any command in their page is considered a security risk.

  3. As far as I know, there is not a portable way to pass your CGI parameters. Apache supports environment variables. IIS supports a parameter string but not vice versa

Hope this helps


--mandog

Replies are listed 'Best First'.
Re: Re: Append script output to complex block of html and script
by cfreak (Chaplain) on Sep 07, 2001 at 18:11 UTC

    Apache supports a parameter string as well, you just have to pass it to the html file itself like this:

    somefile.shtml?param=somevalue¶m2=somevalue ...

    As an answer to the original question... I believe SSI is the way to go. From what I understand you'll just need to remove the beginning tags from the script you create. Another way to do it would be to use HTML::Template (availiable from CPAN). I often mix both HTML::Template and SSI to do the very same thing you are doing but not have any HTML code inside the script itself.

Re: Re: Append script output to complex block of html and script
by jerrygarciuh (Curate) on Sep 07, 2001 at 14:32 UTC
    Thanks mandog! The script works great! Will now attempt to weave it into my return_html subroutine. Yeehaa! jg