Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

SSI within a Perl CGI script

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

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

Hi,

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!

Thanks,

j

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 ApacheParse.pm, 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.

        Thanks,

        j

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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (8)
As of 2024-04-25 11:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found