Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

when I am using the below scripts I am getting error msg.

use strict; use LWP::UserAgent; my $ua = LWP::UserAgent->new; my $ua->agent("MyApp/0.1 "); my $req = HTTP::Request->new(POST => 'http://search.cpan.org/search'); $req->content_type('application/x-www-form-urlencoded'); $req->content('query=libwww-perl&mode=dist'); my $res = $ua->request($req); if ($res->is_success) { print $res->content; } else { print $res->status_line, "\n"; }

Error Msg:

Can't call method "agent" on an undefined value at de.pl line 5.

I copied the "LWP::UserAgent" module then I don't know why..

Kindly help in this regard

Replies are listed 'Best First'.
Re: Error Msg of LWP::UserAgent
by PodMaster (Abbot) on Feb 24, 2005 at 05:20 UTC
    Add use diagnostics; and run the script again, and the message will be explained in more detail.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

Re: Error Msg of LWP::UserAgent
by ikegami (Patriarch) on Feb 24, 2005 at 05:28 UTC
    You have a my on line 5 that shouldn't be there. (Copy and paste error?)