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

Hi Monks, i have a perl page count program and am trying to make it run every time the index page of my site is loaded. How can i do this? I have tried to put this in the <body> tag... <BODY onload="counter.cgi"> but this seems to look for a script written inside the html document, not in the directory. Thanks guys. Thanks for the help, i managed to call it from a javascript function which was called when the page loads up.

Replies are listed 'Best First'.
Re: Perl on page load
by beable (Friar) on Jul 11, 2004 at 01:40 UTC

      You can do the same with frames/iframes but of course the single pixel image is the usual way.

      cheers

      tachyon

Re: Perl on page load
by BUU (Prior) on Jul 11, 2004 at 01:50 UTC
    You seem to be under a missaprehension. Perl, as a cgi, is only invoked when the browser makes a request to a server and that server determines that request to be handled by a cgi script. The only way a perl script will be run is if you configure the server to execute it in response to some query.
Re: Perl on page load
by kiat (Vicar) on Jul 11, 2004 at 04:43 UTC
    Hi rtlm,

    How about using exec?

    <!--#exec cgi="/cgi-bin/counter.cgi" -->
    Do read the following for its usage though (source->http://www.tech.irt.org/articles/js099/):
    I have saved this one (exec) for last, since it is probably the most powerful but also the most dangerous. With it, the output of a CGI script may be included where the SSI is in the HTML page. The CGI script may do just about anything - it could be a counter, perhaps, which updates your counter file and displays the number of visitors on the page. It takes two different parameters, cmd and cgi.