programming-examples/perl/Subroutine/Call sub.pl
2019-11-15 12:59:38 +01:00

17 lines
249 B
Perl

#!/usr/bin/perl
use warnings;
use strict;
sub do_list {
my ($subref, @in) = @_;
return map { &$subref ($_) } @in;
}
sub add_one {
return $_[0] + 1;
}
$, = ",";
print do_list (\&add_one, 1, 2, 3); # prints 2, 3, 4