Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
sub sub1 { print "one\n" }
sub sub2 { print "two\n" }
sub sub3 { print "three\n" }
foreach $x (1..3) {
print "running sub #$x :\n";
&{"sub$x"};
}
ejaggers said:I'm not that familiar with references
use strict;
use warnings;
my %coms = (
foo => \&foo,
bar => \&bar,
);
foreach my $x qw(foo bar) {
print "running sub $x :\n";
$coms{$x}->($x);
}
sub foo {
my $arg = $_[0];
print "in $arg sub\n";
}
sub bar {
my $arg = $_[0];
print "in $arg sub\n";
}