Perl URL - an easy way to download URL contents

Perl URL FAQ: What is the easiest way to download the contents of a URL with Perl?

The easiest way I know to download the contents of a URL (i.e., "http://...") using Perl is to use the libwww-perl library, LWP.pm.

Once you have that Perl module installed, the code to download a URL looks like this:

#!/usr/bin/perl

use LWP::Simple;
$url = get 'http://www.DevDaily.com/';

At this point the variable $url contains the contents of the URL you specified. From here you can print the URL, or otherwise manipulate it in your program.

For many other options, see the Perl LWP.pm module and lwpcook.pod documentation!

 

Add new comment

The content of this field is kept private and will not be shown publicly.

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.