Command-Line Program Patterns
Argument Lists
Model a command argument list with fixed local values.
argument-lists
Command-line programs receive a list of words. In examples, a local list can show the same indexing and counting ideas without depending on the process that started the program.
Argument Lists
argv_simulation.pl
Replay: real traced execution (multi-file project)
use strict;
use warnings;
my $command = "build";
my $argument_count = 1;
my $summary = "command:$command";
print "count=$argument_count\n";
print "command=$command\n";
print "summary=$summary\n";
use strict;
use warnings;
my $command = "test";
my $argument_count = 1;
my $summary = "command:$command";
print "count=$argument_count\n";
print "command=$command\n";
print "summary=$summary\n";
use strict;
use warnings;
my $command = "help";
my $argument_count = 1;
my $summary = "command:$command";
print "count=$argument_count\n";
print "command=$command\n";
print "summary=$summary\n";
$command ← build, $argument_count ← 1, $summary ← command:build
4my $command→ build = "build"; #@command="test", "help"5my $argument_count→ 1 = 1;6my $summary→ command:build = "command:$commandbuild";78print "count=$argument_count1\n";9print "command=$commandbuild\n";10print "summary=$summarycommand:build\n";outputcount=1 command=build summary=command:build
$command ← test, $argument_count ← 1, $summary ← command:test
4my $command→ test = "test";5my $argument_count→ 1 = 1;6my $summary→ command:test = "command:$commandtest";78print "count=$argument_count1\n";9print "command=$commandtest\n";10print "summary=$summarycommand:test\n";outputcount=1 command=test summary=command:test
$command ← help, $argument_count ← 1, $summary ← command:help
4my $command→ help = "help";5my $argument_count→ 1 = 1;6my $summary→ command:help = "command:$commandhelp";78print "count=$argument_count1\n";9print "command=$commandhelp\n";10print "summary=$summarycommand:help\n";outputcount=1 command=help summary=command:help