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

Edited by Corion for readability

hi,this is my first petition...so i found this page..just seeking for helps...:)...can anybody help me on how to call other html or shtml file in which that file got ssi and java script....my example on working on it is as below....

$url = "http://www.website.com/test.shtml"; print "Location: ",$url "\n";
and also another one is.....
$file="/var/apache/htdocs/test.shtml"; open(FILE,"$file"); while(<FILE>){ print $_; } exit;

those above scripts i used inside the cgi file just to call other html rather than using print <<EndHTML or start_html()...in which if i used it,it will be very long.can anybody help me on how to solve this problem so that when i call shtml file it will perform the ssi and also java script together.....thank u in advance....

Originally posted as a Categorized Question.

Replies are listed 'Best First'.
Re: calling html
by Jouke (Curate) on Sep 19, 2000 at 16:11 UTC
    I'm a little confused about what you are trying to do here. If it's your intention to process the SSI-directives while your CGI-script reads the file and prints it to STDOUT, it won't work.
    The processing of the SSI directives will be done by the webserver only because it detects the file-extension .shtml. Since the server now processes your CGI script (ending in .cgi or .pl), it does not know that it is supposed to interpret the directives...

    HTH

    Jouke

    Originally posted as a Categorized Answer.

Re: calling html
by Fastolfe (Vicar) on Sep 19, 2000 at 17:59 UTC
    Not 100% sure what you're trying to do here.

    In your first example, you're just giving the browser an HTTP redirect. The browser re-requests from the server the URL that you give it, so the server is in turn parsing the SSI embedded in the HTML as if the browser requested that page originally. That's probably the "best" way of sending the user to a different HTML page.

    Your second example is keeping the user in your CGI but having the CGI script print out the contents of the file. Since your CGI script is not doing any interpolation/parsing of the data before it gets sent, no SSI can be handled, and the server will not post-parse your CGI output for SSI directives.p> In this latter case, if it's SSI features in Perl that you want, I don't believe there are any modules out there that will do this, so you'll have to roll your own. I'd see if Apache::SSI has something useful you can borrow. You'll probably end up having to use some regular expressions or even go so far as HTML::Parser if you want to be accurate about it, pull out the SSI "comments" and run them through your own code. There's got to be a better way of doing what you're trying to do, though.

    Good luck.

    Originally posted as a Categorized Answer.