in reply to cookie encoding

Generally speaking, one way of finding problems with CGI's is to run them from the prompt and see what they say (especially useful if you add warnings: #!/usr/bin/perl -w). If you need %ENV variables you can add them with something like "export SERVER_SOFTWARE=IIS" (if you use bash) before running the script.