Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6891747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:26:56+00:00 2026-05-27T06:26:56+00:00

Using Perl, I’m looking for a simple way to perform a handful of HTTP

  • 0

Using Perl, I’m looking for a simple way to perform a handful of HTTP requests in parallel, where I get responses back in the same order I sent them after they complete, e.g.:

my ($google, $perl) = foobar(GET => 'http://www.google.com/',
                             GET => 'http://www.perl.org/');

Is there a module I should be looking at?

I know I can do the bookkeeping by hand, but I feel spoiled after being able to do this using jQuery’s when method, and I’d love to have as simple a solution using Perl.

Thanks for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:26:57+00:00Added an answer on May 27, 2026 at 6:26 am
    use threads;
    use LWP::UserAgent qw( );
    
    my $ua = LWP::UserAgent->new();
    my @threads;
    for my $url ('http://www.google.com/', 'http://www.perl.org/') {
       push @threads, async { $ua->get($url) };
    }
    
    for my $thread (@threads) {
       my $response = $thread->join;
       ...
    }
    

    The best part is that the parent doesn’t wait for all requests to be completed. As soon as the right request is completed, the parent will unblock to process it.


    If you used Parallel::ForkManager or something else where you can’t wait for a specific child, you can use the following code to order the results:

    for my $id (0..$#urls) {
       create_task($id, $urls[$id]);
    }
    
    my %responses;
    for my $id (0..$#urls) {
       if (!exists($responses{$id})) {
          my ($id, $response) = wait_for_a_child_to_complete();
          $responses{$id} = $response;
          redo;
       }
    
       my $response = delete($responses{$id});
       ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Perl stat() function to get the size of directory and its
I'm using Perl to perform some file cleansing, and am running into some performance
I'm using Perl's XML::Simple to parse deeply nested XML and would like to extract
I am using Perl readdir to get file listing, however, the directory contains more
When using Perl's Net::Jabber , sending a simple message to an offline user causes
I'm using Perl/CGI/Apache and want to fetch the X-Forwarded-For HTTP header. How do I
I'm using Perl 5.10.6 on Mac 10.6.6. I want to execute a simple search
Using Perl, how do I check if a particular Windows process is running or
At work I'm using Perl 5.8.0 on Windows. When I first put Perl on,
I have trouble using Perl grep() with a string that may contain chars that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.