in reply to Re^2: making a loop script with a remote URL call faster
in thread making a loop script with a remote URL call faster

I have problems to understand your code. Your indentation is misleading, most probably because you mix tab with whitespace.

Your infinite loop will execute "continue on with my perl code" many times with old $pricing till it's finally updated again after 60 sec. Is this really what you want? Or should it rather only be executed again if $pricing was updated?

Anyway

> I'm looking to avoid the 0.2 second time it takes Net::Curl to respond with the pricing from the API it's calling.

you should update the $time just after the if-condition, before calling Net::Curl.

Like this you won't include the lag

my pricing = 0; my $time = 0; while (1) { if (time() >= ($time + 60)) { # updates the pricin +g ... $time = time(); # start interval # ... Net::Curl to remote URL... request here. $pricing = [from net::curl]; } # ... continue on with my perl code # even with old pric +ing }

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery