Beefy Boxes and Bandwidth Generously Provided by pair Networks BBQ
P is for Practical
 
PerlMonks

Uninitialized $scheme variable in LWP::Protocol and LWP::UserAgent problem

by rogerd (Sexton)
 | Log in | Create a new user | The Monastery Gates | Super Search | 
 | Seekers of Perl Wisdom | Meditations | PerlMonks Discussion | 
 | Obfuscation | Reviews | Cool Uses For Perl | Perl News | Q&A | Tutorials | 
 | Poetry | Recent Threads | Newest Nodes | Donate | What's New | 

on Jul 27, 2008 at 12:39 UTC ( #700362=perlquestion: print w/ replies, xml ) Need Help??
rogerd has asked for the wisdom of the Perl Monks concerning the following question:

Hello, maybe my problem is trivial, but I cannot find an answer. I will try to explain you what is going on.

The simplest problem to explain is when I try to download a module using cpan. I always get the error:

Fetching with LWP: ftp://mirrors.localhost.net.ar/pub/mirrors/CPAN/authors/id/whatever Use of uninitialized value in hash element at /Library/Perl/5.8.6/LWP/ +Protocol.pm line 53. Use of uninitialized value in pattern match (m//) at /Library/Perl/5.8 +.6/LWP/Protocol.pm line 56. Use of uninitialized value in concatenation (.) or string at /Library/ +Perl/5.8.6/LWP/Protocol.pm line 36. Use of uninitialized value in string eq at /Library/Perl/5.8.6/LWP/Use +rAgent.pm line 199.

The extracted lines where the errors come from are:

Protocol.pm line 53 my $ic = $ImplementedBy{$scheme}; line 56 return '' unless $scheme =~ /^([.+\-\w]+)$/; # check valid + URL schemes line 36 my $impclass = LWP::Protocol::implementor($scheme) or UserAgent.pm line 199 if ($scheme eq "https") {

So, it seems that I have a problem with the assignement of a value to the variable $scheme. Other scripts that use LWP::UserAgent and LWP::Protocol give me the same type of errors, but I write down more explicitely the problem with the cpan modules because they should be more familiar for you.

All I could find about $scheme had something to do with setting or using proxies, is that true? I have no proxies set in my configuration, or they have been assigned automatically by my ISP, I don't know about that.

So, some questions arise: what can I do to solve that problem? Where I can find more information? Where I should start reading? What is that $scheme variable?

Thank you in advance for your help.

Roger

Comment on Uninitialized $scheme variable in LWP::Protocol and LWP::UserAgent problem
Select or Download Code
Re: Uninitialized $scheme variable in LWP::Protocol and LWP::UserAgent problem
by Anonymous Monk on Jul 27, 2008 at 13:03 UTC
    don't use -w, use warnings, and you won't get those warnings :)

      See Injecting a filter into warn() for more information. I fought with this for a while before it clicked. use warnings instead of -w if you don't want to report warnings from included modules.

      --MidLifeXis

Re: Uninitialized $scheme variable in LWP::Protocol and LWP::UserAgent problem
by Anonymous Monk on Jul 27, 2008 at 13:09 UTC
    upgrade LWP
      I upgraded LWP, LWP::Protocol and LWP::UserAgent, and they seem to be upgraded. I continue getting the same errors.
Re: Uninitialized $scheme variable in LWP::Protocol and LWP::UserAgent problem
by jethro (Vicar) on Jul 27, 2008 at 13:59 UTC
    It seems from the use in LWP::UserAgent that $scheme is just the first part of a http address, like 'https', 'http', 'file' ...

    The code in UserAgent uses the scheme of the http address it wants to access, except when it has to go through a proxy. Then it uses the scheme of the proxy instead.

    I'm only making wild guesses now, but your problem could still come from the proxy handling. You might check your environment variables, maybe there is a malformed proxy definition there:

    #bash set | grep -i proxy #csh/tcsh printenv | grep -i proxy
    I would also recommend deleting .cpan in your homedir (or roots homedir) and so resetting your configuration of cpan. Since you have these problems with other scripts too, the chance that this will help is not very high but doesn't hurt to try

    You might create a minimal LWP program (just accessing a web page), and use LWP::Debug to create a logfile. Check the logfile or post it here (together with the version of perl you are using).

    UPDATE: minor clarification

      Thank you. I discovered that my environment variables FTP_PROXY and HTTP_PROXY where been set to some value that I used at the University. I set manually those variables to qw{} and now I don't get the errors. I also could run a small script using LWP that used to fail, and it works.

      Now, I have the problem that some program is automatically setting the proxy environment variables to that value, and I have to manually reset them to reflect my actual network configurations. I have to discover which program is doing that.

      Also, I have to learn some more about proxies, and how to use them with LWP.

      Thank you again... I have now a lot of read and work, but at least I know where to start.

Login:
Password
remember me
What's my password?
Create A New User

Node Status?
node history
Node Type: perlquestion [id://700362]
Approved by bingos
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (19)
Corion
GrandFather
shmem
toolic
holli
Gavin
atcroft
kennethk
scorpio17
thezip
Eyck
pileofrogs
clinton
Utilitarian
ramrod
ssandv
MikeDexter
ReturnOfThelonious
im2
As of 2010-02-09 20:37 GMT
Sections?
The Monastery Gates
Seekers of Perl Wisdom
Meditations
PerlMonks Discussion
Categorized Q&A
Tutorials
Obfuscated Code
Perl Poetry
Cool Uses for Perl
Perl News
Information?
PerlMonks FAQ
Guide to the Monastery
What's New at PerlMonks
Voting/Experience System
Tutorials
Reviews
Library
Perl FAQs
Other Info Sources
Find Nodes?
Nodes You Wrote
Super Search
List Nodes By Users
Newest Nodes
Recently Active Threads
Selected Best Nodes
Best Nodes
Worst Nodes
Saints in our Book
Leftovers?
The St. Larry Wall Shrine
Offering Plate
Awards
Craft
Snippets Section
Code Catacombs
Quests
Editor Requests
Buy PerlMonks Gear
PerlMonks Merchandise
Planet Perl
Perlsphere
Use Perl
Perl.com
Perl 5 Wiki
Perl Jobs
Perl Mongers
Perl Directory
Perl documentation
CPAN
Random Node
Voting Booth?

What level of existential comfort do you require?

Palace
Executive suite at the best hotel
Regular hotel in a decent part of town
Motel
Boarding house
Sleeping Bag on Couch in Basement
Any port in a storm
Camping under the freeway overpass
Jail
Other

Results (279 votes), past polls