in reply to Re: Use of unitialized variable?
in thread Use of unitialized variable?

Actually, you will save yourself a lot of trouble by using LWP and HTTP::Request, like so:
use strict; use LWP::UserAgent; use HTTP::Request::Common; print &getHTML('http://www.perlmonks.org'); sub getHTML($) { # one $ means one scalar arg - for us humans my $url = shift; #create a new agent and name it my $ua = new LWP::UserAgent; $ua->agent("Shmozilla/0.1 " . $ua->agent); #create new request my $req = new HTTP::Request GET => $url; #send the and try to get a response my $resp = $ua->request($req); return ($resp->is_success) ? $resp->content : "Error\n"; }

Replies are listed 'Best First'.
RE: RE: Re: Use of unitialized variable?
by merlyn (Sage) on Aug 29, 2000 at 05:40 UTC
      Yep, you are right - in my haste I overlooked that each call to sub getHTML instantiates a new agent.
      What a waste!! :0

      One more time:

      use strict; use LWP::Simple; print &getHTML('http://www.perlmonks.org'); sub getHTML($) { my $url = shift; my $content = get($url); return getprint($url); }