Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > LWP Package issue in my script..

Reply
Thread Tools

LWP Package issue in my script..

 
 
schimata@gmail.com
Guest
Posts: n/a
 
      03-07-2007

Hi guys,

I ahve the following code:

++++++++++++++++++++++++

use Cwd;
use XML:arser;
use LWP::Simple;
use HTTP::Status;
use LWP::UserAgent;

blah..blah..

blah..


my $ua = LWP::UserAgent->new;


$ua->timeout(1000);
$ua->env_proxy;
# $ua->credentials( 'tracker:80', 'tracker', 'hello' => 'abcd@123' );

my $url ='http://tracker/cfdocs/proddev/admin/ws/api/
get_all_subfeatures.cfm';
print "hello";
my $response = $ua->get($url);

+++++++++++++++++++++++++++++++

Now when I run this script, I get the following error:
++++++++++++++++++++++++++++++++++++++++++++++++++ ++
Can't locate object method "get" via package "LWP::UserAgent" at C:\cq
\featurexml.pl line 37.
++++++++++++++++++++++++++++++++++++++++++++++++++ ++

I think that it is the issue with the LWP stuff here. I see the below
versions of perl and LWP:
++++++++++++++++++++++++++++++++++++++
C:\cq>perl -v
This is perl, v5.6.0 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-2000, Larry Wall
Binary build 623 provided by ActiveState Tool Corp. http://www.ActiveState.com
Built 16:27:07 Dec 15 2000


C:\cq>perl -MLWP -e "print $LWP::VERSION"
5.48
+++++++++++++++++++++++++++++++++++++++

Do I need to re-compile LWP pachage? Any pointers here?

Thanks,
Srini

 
Reply With Quote
 
 
 
 
Uri Guttman
Guest
Posts: n/a
 
      03-07-2007
>>>>> "s" == schimata <(E-Mail Removed)> writes:

s> use LWP::Simple;
s> use HTTP::Status;
s> use LWP::UserAgent;

you don't need all three of those. LWP::Simple will load LWP::UserAgent
which will load HTTP::Status. and by loading all those you are confusing
yourself below.

s> blah..blah..
s> blah..

that isn't valid perl code!

s> my $ua = LWP::UserAgent->new;

so you are using the OO style with that module. read ITS docs on what
methods it supports.

s> $ua->timeout(1000);
s> $ua->env_proxy;

those are legit methods for that object.

s> my $url ='http://tracker/cfdocs/proddev/admin/ws/api/
s> get_all_subfeatures.cfm';

be careful when pasting in emails. that line wrapped and shouldn't have
and if someone cut/pasted it, it would likely fail because of the
newline in the url.

s> print "hello";
s> my $response = $ua->get($url);

ahh. is get() a method documented in LWP::UserAgent? no it isn't. it is
an exported sub in LWP::Simple which wraps code around its own $ua. so
you either call get() as a sub or use $ua and its methods. you can't
mix/match them.

uri

--
Uri Guttman ------ http://www.velocityreviews.com/forums/(E-Mail Removed) -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
 
Reply With Quote
 
 
 
 
Tad McClellan
Guest
Posts: n/a
 
      03-08-2007
Uri Guttman <(E-Mail Removed)> wrote:
>>>>>> "s" == schimata <(E-Mail Removed)> writes:


> s> blah..blah..
> s> blah..
>
> that isn't valid perl code!



He just has a few too many dots.

blah..blah.
blah

There, that's better.


--
Tad McClellan SGML consulting
(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
Mumia W.
Guest
Posts: n/a
 
      03-08-2007
On 03/07/2007 01:29 PM, Uri Guttman wrote:
>>>>>> "s" == schimata <(E-Mail Removed)> writes:

>
> s> use LWP::Simple;
> s> use HTTP::Status;
> s> use LWP::UserAgent;
>
> you don't need all three of those. LWP::Simple will load LWP::UserAgent
> which will load HTTP::Status. and by loading all those you are confusing
> yourself below.
>
> s> blah..blah..
> s> blah..
>
> that isn't valid perl code!
>
> s> my $ua = LWP::UserAgent->new;
>
> so you are using the OO style with that module. read ITS docs on what
> methods it supports.
>
> s> $ua->timeout(1000);
> s> $ua->env_proxy;
>
> those are legit methods for that object.
>
> s> my $url ='http://tracker/cfdocs/proddev/admin/ws/api/
> s> get_all_subfeatures.cfm';
>
> be careful when pasting in emails. that line wrapped and shouldn't have
> and if someone cut/pasted it, it would likely fail because of the
> newline in the url.
>
> s> print "hello";
> s> my $response = $ua->get($url);
>
> ahh. is get() a method documented in LWP::UserAgent? no it isn't.


The method is there. I am able to run Schimata's program after changing
the URL. Evidently, the program Schimata posted is not the one with the
problem.

> it is
> an exported sub in LWP::Simple which wraps code around its own $ua. so
> you either call get() as a sub or use $ua and its methods. you can't
> mix/match them.
>
> uri
>


You are correct though in that using both LWP::Simple and LWP::UserAgent
is redundant.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl LWP Issue with JSP's tommo_blade Perl Misc 1 04-16-2008 07:00 PM
lwp package head question T W Hu Perl Misc 3 08-16-2005 08:38 PM
single package import v/s the entire package Parvinder Java 6 02-27-2005 02:02 PM
package module import name clash with global package George P Python 3 09-11-2004 01:19 PM
Importing a package and looping through modules in the package Dave Python 2 02-10-2004 08:14 PM



Advertisments