Advertisement
Guest User

Untitled

a guest
Mar 24th, 2012
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.91 KB | None | 0 0
  1. sub urlloop {
  2.     my $data;
  3.     my $delay = Mojo::IOLoop->delay(sub {
  4.       # my ($delay, @titles) = @_;
  5.       # Dwarn @titles;
  6.     });
  7.     print "Starting\n";
  8.     my $ua    = Mojo::UserAgent->new;
  9.     for my $url ('http://cloud.mrono.net/cgi-bin/test.cgi') {
  10.         $ua->get($url => $delay->begin);
  11.     }
  12.     my (@sites) = $delay->wait;
  13.     foreach my $tx (@sites) {
  14.         #Manage the data to address the individual sites
  15.         my $return = from_json($tx->{'res'}{'content'}{'asset'}{'content'});
  16.         # my $return2 = from_json($return->{'content'});
  17.         $data->{$return->{'response'}{'result'}{'call_queue'}{'account_id'}} = $return;
  18.         got_all_urls($data);
  19.     }
  20. }
  21.  
  22. sub got_all_urls {
  23.     my ($data) = @_;
  24.     for my $tx ( keys %$data ) {
  25.         Dwarn $data->{$tx};
  26.     }
  27.     Mojo::IOLoop->timer($timeout => sub { Mojo::IOLoop->stop });
  28.     Mojo::IOLoop->start;
  29.     urlloop();
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement