Gossamer Forum
Home : General : Perl Programming :

SSI and CGI output [W/ CGI Scripts in general not just web adverts]

Quote Reply
SSI and CGI output [W/ CGI Scripts in general not just web adverts]
Hi,
I know there is alot of documentation on simulating ssi calls w/ web adverts. For example in the web adverts documentation he has this:
------------------------------------
sub insertadvert {
require "/full/path/to/ads_display.pl";
$adverts_dir = "/full/path/to/ads";
$display_cgi = "http://foo.com/ads/ads.pl";
$advertzone = "";
$ADVUseLocking = 1;
$ADVLogIP = 0;
$DefaultBanner = "";
$ADVNoPrint = 1;
&ADVsetup;
}

---------------------------

My question is referring to scripts in general. I have this very small script that inserts the content of a text file into certain specified areas of my site. I am customizing this recommend script to fit my site layout and I wanted to know what code or lines of code i should use to simulate the ssi call w/ this script. Is there a standard or does it depend on the script that i am calling.

If this is any help here is the script that i use to insert the contents of the text file:

-------------------------------------
#!/usr/local/bin/perl
{
&PlugIt;
}

sub PlugIt
{
$plugit="copyright.txt";

open (PLUG,$plugit) | | die "can't open $plugout";
$plugit="";
while (<PLUG> ){$plugit .=$_;}
close(PLUG);

print "Content-type: text/html\n\n";
print "$plugit";

}
1;
-----------------------------

thanks in advance.
Quote Reply
Re: SSI and CGI output [W/ CGI Scripts in general not just web adverts] In reply to
Except that as soon as you 'require "plugit.pl"', it's going to run the script. You'll need to remove:

{
&PlugIt;
}

out of plugit.pl.

Cheers,

Alex
Quote Reply
Re: SSI and CGI output [W/ CGI Scripts in general not just web adverts] In reply to
This would be very simple to do. Simply insert the following near the top of your script:

require plugit.pl;

Make sure the name of your program is plugit.pl, or change the name of the required library to allow it. Then, whenever you need to output the file, simply do:

&PlugIt;

The output will occur at that point in your program. Yes, it is THAT easy!


------------------
Fred Hirsch
Web Consultant & Programmer
Quote Reply
Re: SSI and CGI output [W/ CGI Scripts in general not just web adverts] In reply to
Thanks for the help.
I have another question. If i take this:
{
&PlugIt;
}

out of the script, will it still work when i call it using standard ssi calls? Or should I have a copy for the pages that are not cgi generated and another for the ones that are?

thanks in advance.
Quote Reply
Re: SSI and CGI output [W/ CGI Scripts in general not just web adverts] In reply to
True Alex, and good point. Yes, you would need to make a copy, and use the copy for inside the CGI's.. or, you could simply copy the PlugIt subroutine into the program you wish to use it in, (just remember to remove the require at the top, since you now have added the sub directly into the program)


------------------
Fred Hirsch
Web Consultant & Programmer