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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
|
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.