We'll discuss the incremental development of the following program that implements a one-register calculator and keeps state.
while ($x = <STDIN>) {
  ($com, $arg) = split(/ /, $x); 
  print "You have typed: $x"; 
  if ($com =~ /^bye/i) { print "Good-bye!\n"; exit; }
  elsif($com =~ /^add/i) { $acc += $arg; print "Acc is now $acc\n"; }
  elsif($com =~ /^sub/i) { $acc -= $arg; print "Acc is now $acc\n"; } 
  else { print "Acc stays $acc\n"; } 
We thus introduce We discuss later in the lecture how we can implement something similar with CGI and how the implementation method is fundamentally different.