Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

SSI within a Perl CGI script

by jkspl (Initiate)
on Mar 11, 2002 at 16:31 UTC ( #150909=perlquestion: print w/replies, xml ) Need Help??

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


I'm new to Perl and wanted to know if there was a way to use SSI within a Perl CGI script? Basically, the CGI script is being referenced from a web page, which is passing it several variables. Based on those variables, I am running several conditional statements to determine which information to present to the user dynamically via SSI.

Any help would be GREATLY appreciated!



Replies are listed 'Best First'.
Re: SSI within a Perl CGI script
by Sinister (Friar) on Mar 11, 2002 at 16:55 UTC
    I once created a toy module for this, which can parse and handle SSI's and #IF-#ELSE's for Apache.

    It can be found here.

    It is called, OO based and un-documented. (The source is still the documentation)
    I hope it can help you.

    er formait hyarya.
    "Field experience is something you don't get until just after you need it."
      No offense, but with modules for SSI already available on CPAN I can't see a good reason to use something that's not documented.

      Try CGI::SSI or CGI::SSI_Parser, or look at this node for more ideas.

        Thanks everyone for your quick replies!

        Regarding the CGI::SSI module, how do I actually use that? Again, excuse my ignorance, but I am new to using Perl and I'm not 100% clear on how to reference the code.

        Do I save all of the CGI::SSI code to a new file and then reference that module from my script, or paste this new code into my script?

        If anyone has a simple example that they could share with me I would be grateful.



Re: SSI within a Perl CGI script
by talexb (Chancellor) on Mar 11, 2002 at 16:49 UTC
    A Server Side Include is just a line of HTML. So if the Perl CGI script is outputting the contents of a web page, adding an SSI directive has no special meaning to Perl.

    Just output the SSI like any other piece of a web page.

    Update:Sinister is right, an SSI is not just a line of HTML -- it is further processed by the web server. But it still does not have any special meaning to a Perl script.

    --t. alex

    "There was supposed to be an earth-shattering kaboom!" --Marvin the Martian

      Not quitte true! A server-side include is parsed by the webserver. What perl returns is no further parsed by your $WEBSERVER.

      er formait hyarya.
      "Field experience is something you don't get until just after you need it."

        Only if your webserver supports it. If you are using apache (as most people do), you will need to use 2.0 (still in beta) if you want your cgi output to be server-parsed.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://150909]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (2)
As of 2022-10-06 00:57 GMT
Find Nodes?
    Voting Booth?
    My preferred way to holiday/vacation is:

    Results (26 votes). Check out past polls.