我试图弄清楚如何迭代一组子程序参考。
这种语法有什么问题?
use strict;
use warnings;
sub yell { print "Ahh!\n"; }
sub kick { print "Boot!\n"; }
sub scream { print "Eeek!\n"; }
my @routines = (\&yell, \&kick, \&scream);
foreach my $routine_ref (@routines) {
my &routine = &{$routine_ref};
&routine;
}
提前致谢!