Route a command word to a small action label.

Command Dispatch

command_dispatch.pl
use strict;
use warnings;

my $command = ;
my $action = "show-usage";

if ($command eq "run") {
    $action = "execute";
} elsif ($command eq "check") {
    $action = "validate";
}

print "command=$command\n";
print "action=$action\n";
use strict;
use warnings;

my $command = ;
my $action = "show-usage";

if ($command eq "run") {
    $action = "execute";
} elsif ($command eq "check") {
    $action = "validate";
}

print "command=$command\n";
print "action=$action\n";
use strict;
use warnings;

my $command = ;
my $action = "show-usage";

if ($command eq "run") {
    $action = "execute";
} elsif ($command eq "check") {
    $action = "validate";
}

print "command=$command\n";
print "action=$action\n";
command-dispatch Dispatch turns a command word into the branch of work to run. The same pattern works for small tools and larger command groups.