sub map2(&@){ my $code = shift; map $code->( shift, shift ), 0 .. $#_/2 } sub grep2(&@){ my $code = shift; map{ my @pair = (shift,shift); $code->( @pair ) ? @pair : () } 0 .. $#_/2 }