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

Hi.

Is there an alternative to SSI when it comes to calling a Perl script from an html file?

For example, imagine that I run an advertising network which is written in Perl. Since not all of the publishers have SSI capabilities, what alternative code could I give them that would still call the perl scripts?

Thanks,
Ralph :)

Replies are listed 'Best First'.
Re: Alternative to SSI
by Chady (Priest) on May 27, 2001 at 20:48 UTC

    you have to use SSI to take the return values of the ran script..

    or if you just want to run the script, you can call it from an <IMG src="cgi-bin/script.pl"> tag and return an empty image

    Oh... why not just run the script?? and not the html to call it...


    He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.

    Chady | http://chady.net/
Re: Alternative to SSI
by blue_cowdawg (Monsignor) on May 28, 2001 at 02:32 UTC

    What I am not clear on with your question is

    • Does the perl script in question have to live on the publisher's machine?
    • What do you mean exactly by call perl script from HTML?
    I'm thinking that there are all sorts of clever ways of incorporating javascript, img tags, dummy forms, and all sorts of trickery depending on what you are trying to accomplish.

    Give me a more substantial example of what you are trying to call from HTML.

    Updated: Here is one way that I can think of right off the bat that I've actually done in the past:


    In the HTML file you do the following:

    <script type="text/javascript" language="JavaScript" src="http://myserver.domain.com/cgi-bin/script?args=..."> doScript() </script> <script type="text/javascript"> doScript() </script>
    I didn't stutter when I did the "doScript()" twice. For some reason when it is rendered it needs to be called twice.

    At any rate, I think I got that trick from WebMonkey a while back in an article entitled Poor Man's SSI or some such title. If I could find the article I would provide a link to it.

    What may or may not be obvious is the cgi script being referenced should return valid JavaScript code to be executed by the browser and in turn produced the desired renderable HTML code.


    Peter L. BergholdSchooner Technology Consulting, Inc.
    Peter@Berghold.Netwww.berghold.net
Re: Alternative to SSI
by thpfft (Chaplain) on May 28, 2001 at 05:25 UTC

    If the script is on a remote machine, as you say, then SSI won't work anyway: it only works for local addresses.

    Here are a few options that might work:

    <iframe src="http://your_script"></iframe> <a href="your_link"><img src="http://your_script"></a> <script language="javascript" src="your_javascript"></script>

    If you use the image option then your script has to return a valid image file, of course. The javascript would consist of document.write() instructions. iframes can just contain html, but don't work in netscape. There's something similar that you can do with <div> tags in netscape, but i can't remember the syntax for that one. Search for the source-include css property to find out.

    Most of these methods, and perhaps others, can be found by reading the source of pages with adverts on them, but I hope the ad network really is just for example...

Re: Alternative to SSI
by Anonymous Monk on May 28, 2001 at 05:36 UTC
    At last I've ended up using...

    <script type="text/javascript" language="JavaScript" src="script.pl"></script>

    This way turned out to be the most effective for what I needed to do :)

    Thanks to all for your answers! These really helped!

    Ralph :)
Re: Alternative to SSI
by Anonymous Monk on May 28, 2001 at 03:08 UTC
    Peter: The Perl script will live in a remote machine. Let's say the url is http://perlmonks.org/cgi-bin/banners.pl. This script will return html code for a banner to be displayed.

    What I need to find is an alternative to producing this result without having to use SSI. Any ideas?

    Thanks,
    Ralph :)