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