sub map_pairs(&@) { my $f = shift; my @res; no strict 'refs'; no warnings 'once'; my $caller = caller; local(*{$caller."::a"}) = \my $a; local(*{$caller."::b"}) = \my $b; push @res, $f->($a,$b) while ($a, $b) = splice @_, 0, 2; return @res; }