G'day carlriz,

Welcome to the monastery.

In the main, this looks like a well-written piece of code. Were you just looking for comments on the code or are you experiencing some difficulties (e.g. something doesn't work as expected, excessive run time, chews up lots of memory, etc.)?

If the 'x50' (in my @URLs = ...) is related to the THREADS constant, then 'x THREADS' would be a better choice.

I'd probably set the timeout value as a constant (near the top of the script) and keep comments relating to that value there. The current comment refers to testing so presumably that's intended to change during the development cycle. Consider the chances of forgetting to search through the script for $ua->timeout(5) and changing it, against the chances of not spotting TIMEOUT => 5, # for testing near the top; you also won't have to search for $ua->timeout(TIMEOUT) (however many times it occurs) as it won't need modification.

Overall, the layout looks very good and is easy to read. I'd aim to keep lines <= 80 characters (others have different preferences: 72 and 78 characters are common). When lines start to get much longer than this, readability suffers. Consider the readability of one of your lines and the suggested alternative following it:

my %query_hash = (action => 'submit or status', name => 'chris', outn +ame => 'chris', 'content-type' => 'application/json');
my %query_hash = ( action => 'submit or status', name => 'chris', outname => 'chris', 'content-type' => 'application/json' );

Finally, of minor importance and I suspect this may be an artefact of your editor, you have a large amount of extraneous whitespace after many of you lines. Because this is wrapping in my browser (and I suspect this will be true for many others), I actually see your intended

######### # Main # #########

as

######### + # Main # + ######### +

There's many examples of that wrapping issue throughout the code you posted.

-- Ken


In reply to Re: HTTP Requests and Threading by kcott
in thread HTTP Requests and Threading by carlriz

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.