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

I'm new to Web programming through Perl, so please bear with me. I have two questions.

Any insight you can share would be greatly appreciated.

Replies are listed 'Best First'.
Re: sending URL + query string to server?
by almut (Canon) on Jun 02, 2009 at 23:04 UTC
    I don't think I need the CGI module in order to send this to the target Web server

    To send an HTTP request to a server you want LWP::UserAgent (or WWW::Mechanize for more complex tasks).  Server-side, the CGI module may be useful, in particular for getting at the query string parameters.

    Do I have any control over where this print is printed on the Web page?

    What the server does, and what HTML it returns for a certain request, entirely depends on how things are set up. For example, if you send your request to a CGI program server-side, that program could read the query string parameter and embed it into whatever HTML code you like (if you're the one writing the code). In other words, where it is being printed depends on what HTML is being generated  (if I understood your question correctly...)

      Thanks! This helps a lot.

      I think this is the last question. Is it possible to access the fields of a HTML form upon submission within a Perl subroutine? Or do I need send the form to a CGI script which in turn passes on modified parameters to the server? As you can see, I'm wanting to filter information sent to the server.

      Again, thanks. LWP::UserAgent appears to be just want I needed.

        Is it possible to access the fields of a HTML form upon submission within a Perl subroutine?

        The question here is: where would that Perl code be running? How would it receive the requests (form submissions) to filter?

        So yes, one way to do it would be to set up a proxy web server, and then use the CGI approach you're considering. I.e. the CGI program would receive the requests, parse, manipulate and reassemble the query string, and send it as a new request to the target server.

        If setting up a dedicated webserver (like Apache) seems like overkill for that purpose, you might consider using HTTP::Proxy, or some such...