Ask a Question related to PERL Miscellaneous, Design and Development.
-
mUs #1
In loop wait for function return
I would like to loop through a few URL's utilizing the LWP::Simple get function.
Using the existing 'logic' ( or lack thereof ) is there a way to have the
script wait before executing the next iteration of the for loop. At the moment
the 'get' function does not have enough time to complete its' request.
I looked into fork, wait, exec, etc but those don't seem to be what i'm looking
for. I though 'eval' would do it but it doesn't. thanks
#!/usr/bin/perl -w
use strict;
use diagnostics;
use LWP::Simple;
require HTML::TokeParser;
my $url = 'http://localhost/page.html';
my $url2 = 'http://localhost/page2.html';
my $url3 = 'http://localhost/page3.html';
my @urls = qq($url $url2 $url3);
# yes, of course this works
#die "LWP::Simple is empty: $! " unless ( parse_page(my $webPage = get($url)));
# loop does not give LWP::Simple function get enough time to
# return before looping, just dies
for my $page (@urls) {
die "cant get web page: $!\n" unless ( my $webPage = get($page));
# eval does not die, exits with success but nothing sent to
# function
#eval {($webPage = get($page));}; die $@ if $@; # returns ok
#eval {&parse_page($webPage = get($page));}; die $@ if $@; #return ok but
# nothing send to function, script dies
}
sub parse_page {
shift ,etc
}
mUs Guest
-
How to make function wait for HTTPService completion
Dear group, I have a function that creates a new HTTPService(), sends the request and then creates a new ComboBox() intended to display the data... -
Wait function
Is there any way that i can make my application wait for some time so that page loads in that time, right now I am using following code, ... -
Call to webservice doesn't wait to return
Hi All, I have created a ASP.NET web service with a web method. This method retrives data from SQL Server and returns it as an XML string. Now... -
wait loop
Hello, How do I pause my application for a given number of seconds without blocking any other application or user input? I've found the sleep... -
Function/Global var to return name of calling function?
I'm sure I saw this somewhere but can't remember where and can't find it now... Is there a PHP function or global variable that will return name... -
Gregory Toomey #2
Re: In loop wait for function return
"mUs" <cmustard_!SPAM@nyc.rr.com> wrote in message
news:X2dZa.111703$852.20426@twister.nyc.rr.com...function.> I would like to loop through a few URL's utilizing the LWP::Simple getmoment> Using the existing 'logic' ( or lack thereof ) is there a way to have the
> script wait before executing the next iteration of the for loop. At thelooking> the 'get' function does not have enough time to complete its' request.
> I looked into fork, wait, exec, etc but those don't seem to be what i'mThe get function returns a string, usually containing HTML. It generally> for. I though 'eval' would do it but it doesn't. thanks
takes 1-2 seconds to run for me.
If you are saying that the web server at the other end takes a long time to
return you request, or does not return at all, then maybe he URL is wrong or
the web server is overoaded? Have you tried typing the URLs in a browser?
Forking of subprocesses does not solve the underlying problem.
gtoomey
Gregory Toomey Guest
-
Eric J. Roode #3
Re: In loop wait for function return
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
mUs <cmustard_!SPAM@nyc.rr.com> wrote in
news:X2dZa.111703$852.20426@twister.nyc.rr.com:
The script *is* waiting for the 'get' to return before going on to the next> I would like to loop through a few URL's utilizing the LWP::Simple get
> function. Using the existing 'logic' ( or lack thereof ) is there a
> way to have the script wait before executing the next iteration of the
> for loop. At the moment the 'get' function does not have enough time
> to complete its' request. I looked into fork, wait, exec, etc but
> those don't seem to be what i'm looking for. I though 'eval' would do
> it but it doesn't. thanks
iteration of the loop. What are you seeing (versus what you're expecting)
that is causing you to think otherwise?
- --
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print
-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPzWdRGPeouIeTNHoEQJ+kACeK1PREMpNGus4MkEAcJc0rR 7pi6sAoONf
MUsJJ+LnlbeQNSOZSZDbqpuQ
=Ila7
-----END PGP SIGNATURE-----
Eric J. Roode Guest
-
Bart Lateur #4
Re: In loop wait for function return
Eric J. Roode wrote:
>mUs <cmustard_!SPAM@nyc.rr.com> wrote in
>news:X2dZa.111703$852.20426@twister.nyc.rr.com:
>>> I would like to loop through a few URL's utilizing the LWP::Simple get
>> function. Using the existing 'logic' ( or lack thereof ) is there a
>> way to have the script wait before executing the next iteration of the
>> for loop. At the moment the 'get' function does not have enough time
>> to complete its' request.To the OP: check the return status of the request. You won't be able to>The script *is* waiting for the 'get' to return before going on to the next
>iteration of the loop. What are you seeing (versus what you're expecting)
>that is causing you to think otherwise?
do that using get(), but getstore(), which will save the retrieved data
as a file, will at least return the status code. If it's not 200,
something went wrong. More elaborate scripts using LWP::UserAgent can
return you the complete headers.
--
Bart.
Bart Lateur Guest



Reply With Quote

