$ cat 930256_a.pl #!/usr/bin/perl use strict; use warnings; #my @list = (5, undef, 1 .. 9); my @list = (5, 1 .. 9); sub xmap { my $match = shift; my $rc = shift; my @rv=(); for (@_) { push @rv, &$rc($_); last if $_ eq $match; } return @rv; } print "list: ", join(", ", @list), ".\n"; print "xmap: ", join(", ", xmap(7, sub { $_*2 }, @list)),".\n"; $ perl 930256_a.pl list: 5, 1, 2, 3, 4, 5, 6, 7, 8, 9. xmap: 10, 2, 4, 6, 8, 10, 12, 14.