Chapter 16. Process Management and Communication


It is quite a three-pipe problem, and I beg that you won’t speak to me for fifty minutes.

Sherlock Holmes, The Red-Headed League

Perl may be many things to many people, but to most of us it is the glue that connects diverse components. This chapter is about launching commands and connecting separate processes together. It’s about managing their creation, communication, and ultimate demise. It’s about systems programming.

When it comes to systems programming, Perl, as usual, makes easy things easy and hard things possible. If you want to use it as you would the shell, Perl is happy to assist you. If you want to roll up your sleeves for low-level hacking like a hardcore C programmer, you can do that, too.

Because Perl lets you get so close to the system, portability issues can sneak in. This chapter is the most Unix-centric chapter of the book. It will be tremendously useful to those on Unix systems, but only of limited use to others. We deal with features that aren’t as universal as strings and numbers and basic arithmetic. Most basic operations work more or less the same everywhere. But if you’re not using some kind of Unix or other POSIX conformant system, most of the interesting features in this chapter may work differently for you—or not at all. Check the documentation that came with your Perl port if you aren’t sure.

Process Creation

In this chapter, we cover the proper care and feeding of your own child processes. ...

Get Perl Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.