my @commands = ( sub {print "hello\n"}, sub {print "world\n"} ); foreach my $command (@commands) { &{$command}; }