Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

3. The LWP Class Model > 3.3. Inside the do_GET and do_POST Functions

Inside the do_GET and do_POST Functions

You now know enough to follow the do_GET( ) and do_POST( ) functions introduced in Chapter 2. Let’s look at do_GET( ) first.

Start by loading the module, then declare the $browser variable that will hold the user agent. It’s declared outside the scope of the do_GET( ) subroutine, so it’s essentially a static variable, retaining its value between calls to the subroutine. For example, if you turn on support for HTTP cookies, this browser could persist between calls to do_GET( ), and cookies set by the server in one call would be sent back in a subsequent call.

use LWP;
my $browser;
sub do_GET {

Next, create the user agent if it doesn’t already exist:


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint