The most obvious manner in which a program can communicate with the environment is by reading and writing. We are already familiar with how we can write a Perl program that reads from the standard input or from a file, and write out to the standard output or to a file. In this chapter, we learn more about other ways in which a Perl program can have more complex and fruitful interactions with the environment.
When we talk about the environment, we mean dealing with the local environment as well as the non-local environment. Speaking locally, a Perl program may have to communicate requests and get responses back from the operating system on the machine in which the Perl program resides. A Perl program may also want to communicate with other processes that are running on the machine in which the program is running. However interesting such local communication may be, in this era of the Internet and the World Wide Web, Perl programs may need to communicate with a program running on a distant machine, maybe, in the same building or half-way around the world. We will learn how Perl programs can speak
the language that a distant computer understands and communicate back and forth.
This chapter looks briefly at how one calls system functions, and how pipes work as a means for inter-process communication. A substantial part of the chapter discusses how new processes can be created and how processes running on the same computer can communicate. We see that there can be only very limited communication among related processes created using the well-known fork command. Another substantial part of the chapter discusses the concept of sockets, and how processes running on the same or different machines can interact via the use of sockets.