Guest User

Untitled

a guest
Jul 26th, 2018
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 2.03 KB | None | 0 0
  1. #!/usr/bin/env perl
  2. use Mojolicious::Lite;
  3.  
  4. use Mojo::UserAgent;
  5. use Mojo::IOLoop;
  6. use Data::Dumper;
  7.  
  8. # Documentation browser under "/perldoc"
  9. plugin 'PODRenderer';
  10.  
  11.  
  12. my @url_lst = (
  13.     'https://stackoverflow.com/questions/1607904/vim-deleting-from-current-position-until-a-space',
  14.     'https://stackoverflow.com/questions/7409134/english-mnemonics-to-vims-shortcuts?noredirect=1&lq=1',
  15.     'https://stackoverflow.com/questions/102384/using-vims-tabs-like-buffers?rq=1',
  16.     'https://stackoverflow.com/questions/327411/how-do-you-prefer-to-switch-between-buffers-in-vim?noredirect=1&lq=1',
  17.     'https://stackoverflow.com/questions/105721/how-do-i-move-to-end-of-line-in-vim?rq=1',
  18.     'https://stackoverflow.com/questions/235839/indent-multiple-lines-quickly-in-vi?rq=1',
  19.     'https://stackoverflow.com/questions/2332340/indenting-a-bunch-of-lines-in-vim?noredirect=1&lq=1',
  20.     'https://stackoverflow.com/questions/657447/vim-clear-last-search-highlighting?rq=1',
  21.     'https://stackoverflow.com/questions/14863315/highlight-searches-in-vim-but-not-substitutions?noredirect=1&lq=1',
  22.     'https://stackoverflow.com/questions/1497958/how-do-i-use-vim-registers?rq=1',
  23. );
  24.  
  25. my @req_lst;
  26.  
  27. my $ua = Mojo::UserAgent->new;
  28.  
  29. Mojo::IOLoop->singleton->recurring(5 => sub {
  30.         my $j = 0;
  31.  
  32.         #foreach my $j (0..2) {
  33.             foreach my $i (0..4) {
  34.                 $req_lst[$i] = $ua->get_p($url_lst[$i+($j*5)]);
  35.                 print Dumper($url_lst[$i+($j*5)]);
  36.             }
  37.  
  38.             Mojo::Promise->all($req_lst[0], $req_lst[1], $req_lst[2], $req_lst[3], $req_lst[4])->then(sub {
  39.                     my (@lst) = @_;
  40.  
  41.                     #print Dumper(@lst);
  42.                 })->wait;
  43.             #}
  44.     }
  45. );
  46.  
  47.  
  48.  
  49. get '/' => sub {
  50.     my $c = shift;
  51.     $c->render(template => 'index');
  52. };
  53.  
  54. app->start;
  55. __DATA__
  56.  
  57. @@ index.html.ep
  58. % layout 'default';
  59. % title 'Welcome';
  60. <h1>Welcome to the Mojolicious real-time web framework!</h1>
  61. To learn more, you can browse through the documentation
  62. <%= link_to 'here' => '/perldoc' %>.
  63.  
  64. @@ layouts/default.html.ep
  65. <!DOCTYPE html>
  66. <html>
  67.   <head><title><%= title %></title></head>
  68.   <body><%= content %></body>
  69. </html>
Add Comment
Please, Sign In to add comment