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

Hi all,
I have seen on a few scripts that the URL called up can be similar to the following 'hello.pl/me' swapping the ? with / to make it look like a directory, I was just wondering how this is achieved, and is it still possivle to get the following variable $ENV{'QUERY_STRING'}?

Any comments are appreciated, Thanks.

Replies are listed 'Best First'.
Re: Simple Query String Question
by merlyn (Sage) on Sep 27, 2001 at 19:38 UTC
Re: Simple Query String Question
by Rhandom (Curate) on Sep 27, 2001 at 19:51 UTC
    Up front, given a url such as
    http://www.somedomain.com/cgi-bin/cgi.pl/more/path.html?more=info&here=1
    and assuming that /cgi-bin/cgi.pl is the cgi being run you would get the following information:

    $ENV{HTTP_HOST} = 'www.somedomain.com'; $ENV{SCRIPT_NAME} = '/cgi-bin/cgi.pl'; $ENV{PATH_INFO} = '/more/path.html'; $ENV{QUERY_STRING} = 'more=info&here=1'; $ENV{REQUEST_URI} = '/cgi-bin/cgi.pl/more/path.html?more=info&here=1';

    When in doubt, do a Data::Dumper::Dumper(\%ENV) and you will be able to see all of the information in %ENV.

    my @a=qw(random brilliant braindead); print $a[rand(@a)];