problem with use lwp

evertime I try to access lwp in a script i get this message:

Can't locate LWP.pm in @INC (@INC contains: lib /usr/lib/perl5/i386-linux/5.00403 /usr/lib/perl5 /usr/lib/perl5/site_perl/i386-linux /usr/lib/perl5/site_perl

I have a web hosting account with Netcom/Mindspring and they tell me the module 'should' be there. can anyone help me with this?
mercytomAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
shlomoyConnect With a Mentor Commented:
use LWP::Simple qw/$ua/;
0
 
shlomoyCommented:
Seems like LWP wasn't installed (properly).
0
 
christopher sagayamCommented:
How do you call the LWP module ? Can you post the snippet of PERL code here ?
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
mercytomAuthor Commented:
of course,
with respect to the expert who posted it here..

#!/usr/bin/perl -d

use lib "lib";
require LWP;
require URI::URL;

use strict;
use CGI;

my($hdr,$server_response);
my($statement_URL)="http://www.yahoo.com";

$server_response=&browse($statement_URL,$hdr);  ##  Fire the URL

print "Content-type: text/html\n\n";

open(TMP,">/tmp/yahoo.html") || die $!;
print TMP $server_response;
close(TMP);
print $statement_URL," obtained!!<P>\n";
   
sub browse(){
  my($statement_URL,$hdr)=@_;
  my($content_type,$method);

  $content_type="application/x-www-form-urlencoded";
  $method="GET";

  my($headers)= new HTTP::Headers 
    'Content-Type'   =>  $content_type,
    'MIME-Version'   =>  '1.0',
    'Date'           =>  HTTP::Date::time2str(time),
    'Accept'         =>  'text/html';

  my($ua)= new LWP::UserAgent;

  $ua->agent("Mozilla/4.7 [en] (WinNT; U)"); # Define env variable - HTTP_USER_AGENT

  my($url)= new URI::URL($statement_URL);
  my($request)= new HTTP::Request($method, $url, $headers);

  my($response)= $ua->request($request);

  my($reply);

  if ($response->is_success){
    $reply=$response->content;
  }else{
    $reply=$response->error_as_HTML();
  }
  return $reply;
}

0
 
christopher sagayamCommented:
try

use LWP ;

instead of

require LWP;
0
 
shlomoyCommented:
Good advice!
0
 
mercytomAuthor Commented:
Can't locate LWP.pm in @INC (@INC contains: lib /usr/lib/perl5/i386-linux/5.00403 /usr/lib/perl5 /usr/lib/perl5/site_perl/i386-linux /usr/lib/perl5/site_perl .)
0
 
maneshrCommented:
mercytom,

what is the full location of LWP.pm? (Eg /usr/local/lib/LWP.pm)
you can use the UNIX find command to get the location of LWP.pm

find  / -type f -name "LWP.pm" -print 2> /dev/null

NOTE: Since you would be searching the ENTIRE system, this search would be slow.

once you have the full path to LWP.pm, lets say /usr/local/lib

then change .....

use lib "lib";

TO...

use lib "/usr/local/lib";

Let me know how it goes.
0
 
mercytomAuthor Commented:
I called mindspring's tech support and they told me that they couldn't find the module (I have no command line privilige). The suggested that it was in /usr/bin/perl but I get basically the same message when I copy it in place of 'lib' as you suggessted.

Suppose it isn't installed on my server. Can I copy it to a directory on my site? How would I do that?
0
 
mercytomAuthor Commented:
The following script:
#!/usr/bin/perl -d

use lib "/usr/bin/perl";
use LWP;
require URI::URL;

use strict;
use CGI;

my($hdr,$server_response);
my($statement_URL)="http://www.yahoo.com";

$server_response=&browse($statement_URL,$hdr);  ##  Fire the URL

print "Content-type: text/html\n\n";

open(TMP,">/tmp/yahoo.html") || die $!;
print TMP $server_response;
close(TMP);
print $statement_URL," obtained!!<P>\n";
   
sub browse(){
  my($statement_URL,$hdr)=@_;
  my($content_type,$method);

  $content_type="application/x-www-form-urlencoded";
  $method="GET";

  my($headers)= new HTTP::Headers 
    'Content-Type'   =>  $content_type,
    'MIME-Version'   =>  '1.0',
    'Date'           =>  HTTP::Date::time2str(time),
    'Accept'         =>  'text/html';

  my($ua)= new LWP::UserAgent;

  $ua->agent("Mozilla/4.7 [en] (WinNT; U)"); # Define env variable - HTTP_USER_AGENT

  my($url)= new URI::URL($statement_URL);
  my($request)= new HTTP::Request($method, $url, $headers);

  my($response)= $ua->request($request);

  my($reply);

  if ($response->is_success){
    $reply=$response->content;
  }else{
    $reply=$response->error_as_HTML();
  }
  return $reply;
}
Yields this...

Loading DB routines from perl5db.pl version 1 Emacs support available. Enter h or `h h' for help. Can't locate LWP.pm in @INC (@INC contains: /usr/bin/perl /usr/lib/perl5/i386-linux/5.00403 /usr/lib/perl5 /usr/lib/perl5/site_perl/i386-linux /usr/lib/perl5/site_perl .) at /www/home/aboutpaperplus.com/cgi-bin/test2.pl line 4. BEGIN failed--compilation aborted at /www/home/aboutpaperplus.com/cgi-bin/test2.pl line 4. DB::fake::(/usr/lib/perl5/perl5db.pl:2084): 2084: "Debugged program terminated. Use `q' to quit or `R' to restart."; DB<1>
0
 
christopher sagayamCommented:
You can achieve the same functionality using IO::Sockets ,, which comes with the core perl ...
0
 
mercytomAuthor Commented:
I sort of understand that Chris, but isn't that functionality somewhat dwarfed by the elegance of lwp:, html, url and all the other enhancements to Perl?

More importently to me. I'd like to have the tech support for my ISP stop giving me the runaround by saying 'uh, yeah, i think it's there....' or 'Those modules should be there...'

So I'd truly like to understand the problem and take it to my ISP's upstairs tech support people.

0
 
christopher sagayamCommented:
ok Normally You should be able to install PERL modules in your local directory if you have TELNET access ..

Do you have telnet access ? if so upload all the required files to a 'temp' directory and I will give you step by step guidance for installing in local directory ...
0
 
shlomoyCommented:
I'd also add:
use LWP::UserAgent;
0
 
mercytomAuthor Commented:
Sorry chris. no telnet access. no command line access.

0
 
mercytomAuthor Commented:
shlomoy, if the compiler can't find lwp, what would make it find lwp::simple, or useragent?
0
 
christopher sagayamCommented:
If there is NO telnet access then there is NO WAY to install LWP in your LOCAL directory

SO I would advise either

1) change your Hosting provider (or)

2) use IO::Sockets Instead


0
 
mercytomAuthor Commented:
well, now knowing that, perhaps I can apply influence on the isp to install the modules.

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.