1 | #!/usr/bin/perl |
1 | #!/usr/bin/perl |
2 | |
2 | |
3 | use Coro; |
3 | use Coro; |
4 | use Coro::Event; |
4 | use Coro::AnyEvent; |
5 | use Coro::LWP; # should be use'd as early as possible |
5 | use Coro::LWP; # should be use'd as early as possible |
6 | use LWP::Simple; |
6 | use LWP::Simple; |
7 | |
7 | |
8 | $SIG{PIPE} = 'IGNORE'; |
8 | $SIG{PIPE} = 'IGNORE'; |
9 | |
9 | |
10 | my @pids; |
10 | my @pids; |
11 | |
11 | |
|
|
12 | for (1..1) { |
12 | push @pid, async { |
13 | push @pid, async { |
13 | print "starting to fetch http://www.google.de/\n"; |
14 | print "starting to fetch http://www.google.de/\n"; |
14 | get "http://www.google.de/"; |
15 | get "http://www.google.de/"; |
15 | print "fetched http://www.google.de/\n"; |
16 | print "fetched http://www.google.de/\n"; |
16 | }; |
17 | }; |
17 | |
18 | |
18 | push @pid, async { |
19 | push @pid, async { |
19 | print "starting to fetch http://www.yahoo.com/\n"; |
20 | print "starting to fetch http://www.yahoo.com/\n"; |
20 | get "http://www.yahoo.com/"; |
21 | get "http://www.yahoo.com/"; |
21 | print "fetched http://www.yahoo.com/\n"; |
22 | print "fetched http://www.yahoo.com/\n"; |
22 | }; |
23 | }; |
|
|
24 | } |
23 | |
25 | |
24 | $_->join for @pid; |
26 | $_->join for @pid; |
25 | |
27 | |