Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: CGI queries without '?'

by ryan (Pilgrim)
on Feb 19, 2001 at 11:52 UTC ( #59352=note: print w/replies, xml ) Need Help??

in reply to Re: CGI queries without '?'
in thread CGI queries without '?'

Indeed it does.

This being the case, can correctly handle such information gathering, or is it up to the programmer to risk it all and handle the variable on their own? ... (I'm not saying I condone this practice)

Replies are listed 'Best First'.
(dkubb) Re: (3) CGI queries without '?'
by dkubb (Deacon) on Feb 19, 2001 at 12:10 UTC

    IMHO it is better to use to access the Path Info string than to access $ENV{PATH_INFO} directly, with the CGI::path_info method. There's alot of good reasons to do this, here are some of mine:

    • CGI deals with implementation issues. If the structure of the %ENV hash ever changed, my code wouldn't break, assuming the module is kept up to date.
    • CGI::path_info corrects common problems in certain web servers, providing a more portable solution than direct access to $ENV{PATH_INFO}.
    • You get documentation of the CGI::path_info method to explain what it does. This means less documentation for me, I like that =) It's much more difficult to find docs explaining the %ENV hash well.
    • It just looks prettier.

    In general, anytime I need to access the %ENV hash, I try to look in's docs for a method to get at the data I want.

      The best reason of all to use's functions to access the ENV hash is that if your URL string happens to contain an unusual character, say a percent sign or a caret, then directly parsing the environmental variables will usually break your program., on the other hand, will seamlessly preserve the unusual character and return it the same way it went in. MS-DOS directory names, for instance, can contain percent signs, so this possibility is not merely theoretical.

      Also, I suspect that a clever hacker may be able to engage in misdeeds by submitting unusual input after the '?' or '/'., which is written by a really brilliant programmer named Lincoln D. Stein, probably screens for at least some types of miscreant CGI input.

      For those who are as clueless concerning as I was a few months ago, it is built into current versions of Perl, so there is no need to download or install it.

      Hail Lincoln Stein! I do not like to engage in hero worship, because we can all be heroic programmers someday, but this piece of open source work by Mr. Stein is really superb.

Re: Re: CGI queries without '?'
by eg (Friar) on Feb 19, 2001 at 11:56 UTC

    ??? It has nothing to do with The pathinfo will be in the %ENV hash.

    my $pathinfo = $ENV{PATH_INFO} || '';

    update: Good point, dkubb. Thanks. I didn't realize I could get the PATH_INFO from CGI itself.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://59352]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2022-01-24 04:30 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (64 votes). Check out past polls.