RE: Problem with LWP::UserAgent
From: Rajesh Dorairajan (rajesh.dorairajan_at_tumbleweed.com)
Date: 02/24/04
- Next message: James Edward Gray II: "Re: Eval Errors"
- Previous message: Charles K. Clarkson: "RE: substitution"
- Maybe in reply to: Rajesh Dorairajan: "Problem with LWP::UserAgent"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
To: dzhuo@looksmart.net Date: Mon, 23 Feb 2004 16:10:34 -0800
Hello David,
First of all, thank you very much for taking the effort to help me solve the
problem. Sorry for the delay in my reply.
> please do not top post. when you reply to any message, post
> your respond
> below the relevant text.
>
Sorry about this. Will make sure I do this future.
> like i say before, your working version and failing version
> is absolutely
> identifical. there is no reason for the failing version to
> fail if the
> working vesion really works.
>
There is a difference. I modifed the original code in order to make sure I
did not break any confidentiality agreement. Let me try to explain again. I
have an xml file that contains a list of URLs. I read these URLs into a
hash and pass them as a parameter into the function that does LWP get. The
code (again abridged) looks like:
$config = XMLin( "config.xml", VarAttr => 'name',
ContentKey => '-content' );
foreach my $keys ( keys %{$config} ) {
foreach (sort keys %{$config->{$keys}} ) {
my $url = $config->{$keys}{$_}; #$url = "http://server:port";
my $retval = testURL( $url );
}
}
sub testURL {
my $url = $_[0];
my $ua = LWP::UserAgent->new( agent => 'Mozilla/1.0',
timeout => 30,
);
my $request = HTTP::Request->new('GET', $url);
my $response = $ua->send_request($request);
my $content = $response->content();
if ( $response->is_success ) {
print $response->content();
else {
print "Failed to get $url\n";
}
}
__END__
#config.xml
<HOSTS>
As already mentioned, in the code above if I substituted the line
my $url = $config->{$keys}{$_};
with,
my $url = "http://server:port";
the function call works just fine. If I use the former statement, I receive
> your best bet is to use the Perl debugger to step through
Thanks again. I use Open PERL IDE under Windows, and I feel it's got a
> --
Thanks again,
Rajesh
<URL_1>http://vasrv1:80>
<URL_2>http://vasrv2:80>
<URL_3>http://vasrv3:80>
<URL_4>http://vasrv4:80
</HOSTS>
a 501 error. I know it's bizzare sice the value contained in the URL (to my
naked eye) is essentially the same. I believe this might've something to do
with converting the XML file to a hash, although I still cannot quite figure
it out.
> your script and
> make sure the variables are getting the values you expected.
> for example,
> assume your script is named net.pl, you can involve the debugger with:
>
> [panda]# perl -d net.pl
>
> and then keep hitting 's<RETURN>' until the debugger is at:
>
> main::(net.pl:9): my $url = $config->{URL_1};
>
> hitting 's<RETURN>' one more time so this line is executed.
> and then type:
>
> print "$url\n";
>
> to see what's the real value of $url. make sure $url has
> exactly what you
> expect. since your script is so simple, you can also put a
> single print
> statement after the assignment to $url and confirm it's
> getting the right
> value. i suggest you learn to use the debugger:
>
> man perldebug
>
> david
extremely good UI debugger. The value I see for $url after the statement in
question is the same in both cases. I still need to try Rob's suggestion to
see the length of the value in both cases, but like I said I feel the
problem originates when I read the XML file into a hash.
> sub'_{print"@_ ";* \ = * __ ,\ & \}
> sub'__{print"@_ ";* \ = * ___ ,\ & \}
> sub'___{print"@_ ";* \ = * ____ ,\ & \}
> sub'____{print"@_,\n"}&{_+Just}(another)->(Perl)->(Hacker)
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>
Relevant Pages
... http://www.TransProCalc.org - Free translation project mgmt software ... set filename tk_getOpenfile ... Exec'ing the script you run it as a separate process, your script won't be able to access its vars. ... generating the xml file is easy enough. ...
(comp.lang.tcl)
... Now, I've made a program, a translation project management tool, ... set filename tk_getOpenfile ... to run the script to reset the variables to reopen the project. ... I've been told that generating an xml file is the best way to go about ...
(comp.lang.tcl)
... du musst den Debugger nicht irgendwie in die "Gänge" setzen. ... So erfolgen die Aufrufe des Debuggers durch den WSH (entweder durch das ... die Aufrufe //D oder //X für das Script. ... > Ich habe den Quelltext von 'quadrat.vbs' in MSE7.EXE geladen. ...
(microsoft.public.de.german.scripting.wsh)
... I have found one web site out there that uses a very similar script to ... digit of the second hash from the "encrypted" (I really don't want to use ... the first character of both are changed by the same ... For example, the first URL is 6 letters long, so ...
(sci.crypt)
... Once you pass that hurdle it is routine selectNodes or selectSingleNode. ... an xml file there is a fat chance that you will never learn how to read one. ... For those who manage to set their server shares via script, ... > I would like to map a set of network drives in which the data fro the ...
(microsoft.public.scripting.wsh)