in reply to Getting the url of referring page

Is there a way to get the url of the page that was used to link to a cgi script, ...

Yes, but not reliably. If the referring page is passed to the web server, it will be available to the CGI in $ENV{HTTP_REFERER}. If you're using CGI.pm, the referer() function will return this value.

The problem is that a few paranoid firewalls will strip the Referer: header from the HTTP request, so you're not guaranteed to get one from 100% of the browsers that might hit your site.