 |
|
Home:
Perl Programming Help:
Advanced:
Re: [mozkill] a muti-threaded web client in perl:
Edit Log
|
|

mozkill
Novice
Apr 1, 2003, 4:23 PM
Views: 2677
|
|
Re: [mozkill] a muti-threaded web client in perl
|
|
|
ok, here is the finished product ------ #!perl.exe use LWP; use HTML::Parse; use HTML::Element; use HTTP::Request; use Thread qw(async); use strict; printf "\n-------\n"; my @children; for (my $i=0;$i<4;$i++) { $children[$i] = async { getIt(); }; } for (my $i=0;$i<4;$i++) { $children[$i]->join(); } sub getIt() { my $ua = LWP::UserAgent->new(); $ua->agent("MyApp/0.1 "); my $url = 'http://web.pdx.edu/~jonw'; my $req = HTTP::Request->new(GET => $url); my $res = $ua->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\n-------\n"; }
(This post was edited by mozkill on Apr 2, 2003, 9:46 AM)
|
|
|
Edit Log:
|
|
Post edited by mozkill
(Novice) on Apr 1, 2003, 5:32 PM
|
|
Post edited by mozkill
(Novice) on Apr 2, 2003, 9:34 AM
|
|
Post edited by mozkill
(Novice) on Apr 2, 2003, 9:46 AM
|
|
|  |