in reply to call sub_function easily
#!/usr/bin/perl # https://perlmonks.org/?node_id=1230776 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 /; my @array = ( $test, $test2, $test3 ); foreach my $array (@array) { $array->() }
|
|---|