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

I am trying to make a web site that is basically run by Perl and there are several problems that I ran into that I couldn't find in any documentation.

When you have a link like this:
<a href="abc.abc?some=thing">Something</a>
How would you access the 'some=thing' part of the URL?

Also, when you have a FORM and the user Submit's it. How do you access the info submitted with the script?

If there is documentation on it that I did not see or find, can you please point me to it. Thanks.

-- Zenon Zabinski

Replies are listed 'Best First'.
Re: Help with Perl for the Net
by athomason (Curate) on Jun 22, 2000 at 20:01 UTC
    Just to clarify, you're trying to process GET/POST form variables. It can be done by hand without too much pain, but Perl is all about not reinventing the wheel. Every intro Perl/CGI book has a different way of doing this, but the answer you'll get from everyone here is using "all-singing, all-dancing" CGI.pm. The module handles both HTML generation and form-processing, but you only need to pick out the functionality you want (I'd highly recommend all of it). It's maintained by Lincoln Stein, so the most current distro and doc is available here. If you're still curious how to do it yourself, there's a good Q&A post on the same topic.
      specifically, you want to try the param method from CGI.pm something like:
      use CGI; $some = param(some);
      should work.
Re: Help with Perl for the Net
by marcos (Scribe) on Jun 22, 2000 at 20:37 UTC
    I do agree with athomason, but if you only need to access from some cgi the "some=thing" part of the URL you have the environment variable QUERY_STRING, which you can access from perl with $ENV{'QUERY_STRING'}.
    marcos
      Don't forget that QUERY_STRING will be URL encoded. (spaces become +, non-word characters become %(hex values)) , which is why CGI.pm is generally used to decode the various possibilities. Nonetheless, sometimes you want a "clean" URL, such as www.mypage.com/detail.cgi?5 , so you can use QUERY_STRING to check that. Note also that you can use QUERY_STRING while using CGI.pm to handle other aspects of CGI programming.