Search code examples
perlcgimod-perl

perl parsing cgi parameters


I remember reading somewhere that it's possible to pass arguments to a perl cgi script as such: www.example.org/cgiscript/arg1/arg2/arg3

I don't remember where I read it and searching didn't help me, so can anybody tell me if this actually works and if yes, how? Is this a mod_perl thing?


Solution

  • Yes. If a CGI script is called from a URL of the form:

    http://example.com/path/to/script.cgi/foo/bar
    

    then the path /foo/bar will be available in the environment variable PATH_INFO.

    If you're using CGI.pm, this is also available in $q->path_info. If you're using mod_perl, Apache2::RequestRec has the same method.