Skip to content

Instantly share code, notes, and snippets.

@olegwtf
Created November 15, 2013 03:05
Show Gist options
  • Save olegwtf/7478457 to your computer and use it in GitHub Desktop.
Save olegwtf/7478457 to your computer and use it in GitHub Desktop.
Mojolicious and AnyEvent
use strict;
use Mojo::Reactor::EV;
use v5.10;
BEGIN {
$ENV{MOJO_REACTOR} = 'Mojo::Reactor::EV';
$ENV{MOJO_IOLOOP_DEBUG} = 1;
}
use Mojo::IOLoop;
use Mojo::UserAgent;
use AnyEvent::HTTP;
use URI;
my $ua = Mojo::UserAgent->new();
for my $url (qw/google.ru mail.ru yandex.ru rambler.ru 2gis.ru/) {
http_get "http://$url/", sub {
say "AE: ", $url;
};
$ua->get("http://$url", sub {
say "Mojo: ", $url;
});
}
Mojo::IOLoop->start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment