[ back to toc ]

Loading a Perl script automatically

Date: 2002/04/22 13:54

Q:
Hi Mr. Verhas,

Is there a way to cause a Perl script to execute when a page is loaded?
There is one that I'd like to have run whenever a user opens a particular
page on my site, and I'd very much appreciate a lead on the HTML required
to code that.

Thanks!
A:
Yes, there are many way, depending on the actual web server you use.

The most general is to write a CGI Perl script and direct the user on the
first page to the URL of the script. The script has to do whatever it
needs to and in addition to that sends the client a redirec header, for
example:

print "Status: 302\nLocation: http://....newpageurl\n\n";

Regards,
Peter

[ back to toc ]