Mike Gossland's Perl Tutorial Course for Windows


CGI In Use | Site Search | Presenting Data | Cookies


Chapter 7. CGI In Use

Requesting Info from Other Servers

Usually you visit a website with a browser and view the retrieved information in the browser window. But with Perl, you can send off the same request that your browser would issue and get the results back into your Perl program instead.

Once it's in your Perl program, you can do whatever you need to with it. The appreciation of the value of this ability is left as an exercise for the reader.

The magic is provided by a popular Perl module, LWP.pm. Just "use" it at the beginning of your perl program to enable it. In summary, you create a new request according to some simple rules, you send it off to the remote server, you wait to get the results back, and you put the results to whatever use you choose.

Here's an example of a request that fetches a website of your choice and reveals all tables present in it. It's a great HTML design aid!

Click here for the request form.

Click here to see the script that handles the request. This form uses the "strict" pragma. It forces you to use Perl in a safe way and is something you should strive to use in your development as a Perl programmer.

prev page next page