my %sub_of = (
1 => sub{ print "program 1" },
2 => sub{ print "program 2" },
3 => sub{ print "program 3" },
4 => sub{ print "program 4" },
5 => sub{ print "program 5" },
6 => sub{ print "program 6" },
7 => sub{ print "program 7" },
8 => sub{ print "program 8" },
9 => sub{ print "program 9" },
);
print "\$fun is $sub_of{'1'}\n";
&{$sub_of{'1'}},
G:\运维系统开发\Tk>perl hash.pl
$fun is CODE(0x20ae50c)
program 1
G:\运维系统开发\Tk>
函数引用
最新推荐文章于 2023-01-05 18:58:46 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)