Hi monks. I have question about method of call sub_function easily. I generate array of sub_function. When I call variable in array, then I expect to execute sub_function. but It is't working.. Do you have easy way to call sub_function. I don't want to write all of sub_function to work.
use strict;
use warnings;
## examples of sub_function.
sub test { print "test\n" }
sub test2 {print "test2\n" }
sub test3 {print "test3\n" }
## pair up variables with sub_function.
my $test = \&test;
my $test2 = \&test2;
my $test3 = \&test3;
my @array = qw/ test test2 test3 /;
## I want to call sub_function each $array. but it is not working..
foreach my $array (@array) {
&$$array
}
## I want to print test test2 test3 like below examples.
## But below examples is not that good way. please help me :)
foreach my $array (@array) {
if($array eq "test" ) { $test }
if($array eq "test2") { $test2}
if($array eq "test3") { $test3}
}