1 #!/usr/bin/perl -w 2 use strict; 3 use warnings; 4 5 #字符串映射函数 6 our %actions = ( 7 "foo" => \&foo, 8 ); 9 10 sub foo11 {12 print "test" ; 13 }14 15 sub main16 {17 my $action = "foo";18 $actions{ $action}->();19 }20 main;
本文共 293 字,大约阅读时间需要 1 分钟。
1 #!/usr/bin/perl -w 2 use strict; 3 use warnings; 4 5 #字符串映射函数 6 our %actions = ( 7 "foo" => \&foo, 8 ); 9 10 sub foo11 {12 print "test" ; 13 }14 15 sub main16 {17 my $action = "foo";18 $actions{ $action}->();19 }20 main;
转载于:https://www.cnblogs.com/trying/archive/2012/12/01/2797134.html