in reply to form cgi

If you look in the documentation for the CGI module, you'll find a section titled, "OBTAINING THE SCRIPT’S URL". I believe the answer to your question lies there.

Update: I misread the question. Never mind.