perl字符串映射函数

前端之家收集整理的这篇文章主要介绍了perl字符串映射函数前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
 1 #!/usr/bin/perl -w
 2 use strict;  3 use warnings;  4 
 5 #字符串映射函数
 6 our %actions = (  7 "foo" => \&foo, 8 );  9 
10 sub foo 11 { 12 print "test" ; 13 } 14 
15 sub main 16 { 17 my $action = "foo"; 18 $actions{$action}->(); 19 } 20 main;

猜你在找的Perl相关文章