Because CGI and Perl originated on UNIX systems, it is necessary to know some basics before we begin.
We need to know a little bit about the client-server model. A client and a server are two different programs running on different (or the same) machine. The client is the program that interacts with the user-displaying graphics, getting input, and sending requests to the server for information. Netscape is an example of a client. The server, is a program that has a relatively simple job--listen for information requests, and send that information out to the requesting client. An example of a server is Apache, a wide-spread web server for Unix machines.
Unix allows many different programs to run at the same time. A Unix program is called a process (because it runs on a microprocessor) and there are many processes running in the background that you don't even know are running. One of these processes is called the http daemon. A daemon is a process that runs in the background, and does not have a controlling terminal. The http daemon acts as the web server, and it listens for requests to send html documents to a remote client.
There are certain "places" the http daemon listens at. These are called ports. Ports are like mail slots where certain types of requests are dropped off. There are many ports, each one with a unique number and a certain type of request to listen for. For example, the http daemon listens to port 80 for http requests. So a client must know to talk to port 80 on a machine in order for it to respond to the request. Other often used ports include port 23 for telnet and 25 for mail.
Because there are so many programs that run on a Unix system, there needs to be some way for processes to communicate with each other. This is accomplished through standard in and standard out (stdio). When a program needs input, it can look at standard input. When it prints output, it can print it to its standard out. The beauty of stdio is that the input can come from a number of sources, and the process does not need to really know where it came from. Common sources of input can be a file, the keyboard, a socket (a stream of data from a network), or a pipe (a input comes in from another process). Common output sources are a file, the terminal screen, a socket, a pipe, or it can be supressed (by sending it to the null device). Piping involves taking the output of one process and sending it as the input of another process. Stdio can be redirected to any one of those common methods.