1 |
root |
1.1 |
#!/usr/bin/perl |
2 |
|
|
|
3 |
root |
1.2 |
use Coro; |
4 |
root |
1.1 |
use Coro::Cont; |
5 |
|
|
|
6 |
root |
1.2 |
sub mul23 : Cont { |
7 |
root |
1.5 |
yield 2*shift; |
8 |
|
|
yield 3*shift; |
9 |
root |
1.2 |
} |
10 |
root |
1.1 |
|
11 |
root |
1.3 |
my %hash = (1,10,2,20,3,30); |
12 |
root |
1.1 |
|
13 |
root |
1.3 |
%hash = map mul23($_), %hash; |
14 |
root |
1.1 |
|
15 |
|
|
print join(",", %hash), "\n"; |
16 |
|
|
|
17 |
root |
1.4 |
# here is a random-number generator |
18 |
|
|
|
19 |
|
|
sub badrand : Cont { |
20 |
|
|
my $seed = 1; |
21 |
|
|
while() { |
22 |
|
|
$seed = $seed * 121 % 97; |
23 |
root |
1.5 |
yield $seed % $_[0]; |
24 |
root |
1.4 |
} |
25 |
|
|
} |
26 |
|
|
|
27 |
|
|
print badrand($_), " " for 1..30; print "\n"; |