
mozkill
Novice
Mar 28, 2003, 3:56 PM
Post #4 of 9
(2540 views)
|
|
Re: [davorg] a muti-threaded web client in perl
[In reply to]
|
Can't Post
|
|
well, here is what i have so far in a .pm file: ------------------------- package LWPThread; use LWP::UserAgent; use HTTP::Request; use HTTP::Response; use strict; use Carp; use LWP::Debug qw(+conns); sub new { my ($class) = @_; my $ua_ref = LWP::UserAgent->new(); bless $ua_ref, $class; testURL($ua_ref); return 1; } sub testURL { my $ua_ref = shift; $ua_ref->agent("perl-LWP\5.6.1"); my $url = 'http://web.pdx.edu/~jonw'; my $req = HTTP::Request->new(GET => $url); my $res = $ua_ref->request($req); my $code = $res->code; my $content = $res->content; if ($res->is_error()) { printf "%s\n", $res->status_line; } else { my $content = $res->content(); } printf $content; } 1; -------------------- and i call it from a perl file like so: ---------------- #! perl.exe -w use lib "C:/Temp/mtlwp"; use LWPThread; use strict; LWPThread->new(); ----------------- in any case, i still cant get it to work. i am having a pass-by-reference issue that is hard to figure out. This code doesnt work "as is". I am still wrestling with it though. All i need is this simple little thing to work. :-(
(This post was edited by mozkill on Mar 28, 2003, 4:08 PM)
|