Win32::Internet

The Win32::Internet extension implements the Win32 Internet APIs (found in WININET.DLL), providing support for HTTP, FTP, and Gopher connections.

All types of connections start as a basic Internet connection that must be opened with the following command:

use Win32::Internet;
$Connection = Win32::Internet->new(  );

This creates an Internet object in Perl on which you use the functions provided in this module to create more specific connection objects. The objects and functions that create them are:

  • Internet connections (the main object, with new)

  • URLs (with OpenURL)

  • FTP sessions (with FTP)

  • HTTP sessions (with HTTP)

  • HTTP requests (with OpenRequest)

This module provides different levels of implementation of the Win32 Internet functions. Some routines use several Win32 API functions to perform a complex task in a single call; they are simpler to use, but less powerful. Other functions implement nothing more and nothing less than the corresponding API function, so you can use all of their power, but with some additional programming steps.

For example, the function FetchURL fetches the contents of any HTTP, FTP, or Gopher URL with a simple command:

$inet = new Win32::Internet(  );
$file = $inet->FetchURL("http://www.yahoo.com");

You can achieve the same result with this series of commands, which is what FetchURL actually does:

$inet = new Win32::Internet(  );
$url = $inet->OpenURL("http://www.yahoo.com");
$file = $url->ReadFile(  );
$url->Close(  );

Get Perl in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.