http://qs321.pair.com?node_id=371184

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

I wrote a CGI script that links back to itself (including GET parameters). I created the link with the following statement:
my $url = "http://$ENV{'SERVER_NAME'}/$ENV{'REQUEST_URI'}";

When I moved my script to the production server, I discovered that REQUEST_URI is not in the environment. My test environment uses Apache and the production environment uses IIS.

Without upgrading the production server to Apache, is there a clean way to get the parameter list? I'm looking at the contents of %ENV, but nothing seems to have the parameters.

My current plan is to use $ENV{'PATH_INFO'} and loop through the parameters to create the URL (only if URI_INFO doesn't exists). The code would look something like:

my $url = "http://$ENV{'SERVER_NAME'}/$ENV{'PATH_INFO'}?"; foreach (param) { $url .= "&$_=" . param($_); }

Is there an easier or better way to do this? I've searched PM and the docs, but nothing's jumping out at me. Thanks.