I’m trying to figure out how to iterate over an array of subroutine refs.
What’s wrong with this syntax?
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;
}
Thanks in advance!