Revision e43cccf4
Von Sven Schöling vor mehr als 15 Jahren hinzugefügt
bin/mozilla/common.pl | ||
---|---|---|
586 | 586 |
local (*A, *B) = @_; # syms for caller's input arrays |
587 | 587 |
|
588 | 588 |
# Localise $a, $b |
589 |
my ($caller_a, $caller_b) = do |
|
590 |
{ |
|
589 |
my ($caller_a, $caller_b) = do { |
|
591 | 590 |
my $pkg = caller(); |
592 | 591 |
no strict 'refs'; |
593 | 592 |
\*{$pkg.'::a'}, \*{$pkg.'::b'}; |
594 | 593 |
}; |
595 | 594 |
|
596 |
my $limit = $#A > $#B? $#A : $#B; # loop iteration limit |
|
597 |
|
|
598 | 595 |
local(*$caller_a, *$caller_b); |
599 | 596 |
|
600 |
# This map expression is also the return value. |
|
601 |
map { my $b_index = $_;
|
|
602 |
map { my $a_index = $_;
|
|
597 |
# This map expression is also the return value.
|
|
598 |
map { my $a_index = $_;
|
|
599 |
map { my $b_index = $_;
|
|
603 | 600 |
# assign to $a, $b as refs to caller's array elements |
604 | 601 |
(*$caller_a, *$caller_b) = \($A[$a_index], $B[$b_index]); |
605 | 602 |
$op->(); # perform the transformation |
606 |
} 0 .. $#A;
|
|
607 |
} 0 .. $#B;
|
|
603 |
} 0 .. $#B;
|
|
604 |
} 0 .. $#A;
|
|
608 | 605 |
} |
609 | 606 |
|
610 | 607 |
1; |
Auch abrufbar als: Unified diff
und nochmal überarbeitet.