cURL / Mailing Lists / curl-library / Single Mail


Re: perl script using libcurl

From: Guenter Knauf <>
Date: Sun, 22 Jul 2007 14:59:32 +0200

> Does nyone have any perl script that simply uses
> libcurl to connect to a server and download the web
> page? I want to test the install of WWW-Curl and
> whether it works with Active State perl.

# simple test script which uses the Perl5 libcurl bindings.

$myurl = $ARGV[0] || '';

use WWW::Curl::Easy;

print "Perl Version: $]\n";
$mtime = (stat('/system/perl.nlm'))[9] if ($^O eq 'NetWare');
$mtime = (stat('/perl/bin/perl.exe'))[9] if ($^O eq 'MSWin32');
print "Binary Fdate: ",scalar localtime($mtime),"\n";
print "OS Name : $^O\n\n";

printf (" Version: %s\n", $WWW::Curl::VERSION);
printf (" Version: %s\n", $WWW::Curl::Easy::VERSION);
printf ("libcurl Version: %s\n\n", WWW::Curl::easy::version());

print ("=" x 78 . "\n");

my $curl = new WWW::Curl::Easy;
$curl->setopt(CURLOPT_USERAGENT, $curl->version());
$curl->setopt(CURLOPT_URL, $myurl);
my $err = $curl->errbuf;
my $info = $curl->getinfo(CURLINFO_HTTP_CODE);

print "$info\n";
print ("=" x 78 . "\n");
print "$err\n" if ($err);

have fun!


Received on 2007-07-22