Hi Monks,

Hoping you can help give me some suggestions on how to speed up this script to avoid the remote URL lag I'm experiencing every 60 seconds.

I am using:

my pricing = 0; my $time = 0; while (1) { if (time() >= ($time + 60)) # updates the pricing on +initial run and every 60 seconds. { Net::Curl to remote URL... request here. $pricing = [from net::curl] $time = time(); } ... continue on with my perl code (needs the $pricing variable to work +) }

The issue I have is that every 60 seconds I am hit with a lag to my script due to the remote URL call. I was wondering if there may be a way to perhaps turn the "Net::Curl" call into a server side localhost script that is updating the pricing constantly and that listens for the client (my main script) and immediately responds with no lag so speeding up the process. Or perhaps Fork off the Net::Curl call inside my main script and update it on a future loop once I get the response back from the remote URL. Max of 1 child process at a time.

If you have any thoughts on how best to accomplish this, code examples, pointers, please let me know. Your help is appreciated.

Thank you


In reply to making a loop script with a remote URL call faster by brandonm78

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.