Place inside an existing CGI that uses CGI.pm.
Pretty self-explanatory, but any argument passed on the URI field of your browser will be turned into a variable used by CGI.pm. Yes, this has several concerns, the most of which is the ability to override the default vars, so remember to always check your variables first when you get them. Using http://www.foo.com/bar=blort&baz=quux will result in $bar=blort and $baz=quux being created for you.
The second piece of that simply prints out the entire environment as passed to your webserver, inside the comment block of your HTML. WARNING: Do not leave this uncommented in production code!!! (unless you want people to see your server paths and other variables, thus making it easier to exploit). Use the second snippet for debugging purposes only!
#!/usr/bin/perl -w use Env; foreach $key ( param() ) { $$key = param($key) unless $$key; } print "<!--\n"; foreach $parameter ( sort keys %ENV ) { print "$parameter is: $ENV{$parameter}\n"; } print "-->\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Creating vars from URI and printing %ENV
by davorg (Chancellor) on Dec 28, 2001 at 16:19 UTC | |
|
Re: Creating vars from URI and printing %ENV
by rob_au (Abbot) on Dec 28, 2001 at 16:03 UTC | |
by crazyinsomniac (Prior) on Dec 28, 2001 at 16:32 UTC | |
by Ovid (Cardinal) on Dec 28, 2001 at 23:10 UTC | |
by chromatic (Archbishop) on Dec 30, 2001 at 08:55 UTC |