Skip to Content
Learning Perl, 6th Edition
book

Learning Perl, 6th Edition

by Randal L. Schwartz, brian d foy, Tom Phoenix
June 2011
Beginner content levelBeginner
386 pages
11h 33m
English
O'Reilly Media, Inc.
Content preview from Learning Perl, 6th Edition

Chapter 16. Process Management

One of the best parts of being a programmer is launching someone else’s code so that you don’t have to write it yourself. It’s time to learn how to manage your children[355] by launching other programs directly from Perl.

And like everything else in Perl, There’s More Than One Way To Do It, with lots of overlap, variations, and special features. So, if you don’t like the first way, just read on for another page or two for a solution more to your liking.

Perl is very portable; most of the rest of this book doesn’t need many notes saying that it works this way on Unix systems and that way on Windows and some other way on VMS. But when you’re starting other programs on your machine, different programs are available on a Macintosh than you’ll likely find on an old Cray (which used to be a “super” computer). The examples in this chapter are primarily Unix-based; if you have a non-Unix system, you can expect to see some differences.

The system Function

The simplest way to launch a child process in Perl to run a program is the system function. For example, to invoke the Unix date command from within Perl, you tell system that’s the program you want to run:

system 'date';

You run that from the parent process. When it runs, the system command creates an identical copy of your Perl program, called the child process. The child process immediately changes itself into the command that you want to run, such as date, inheriting Perl’s standard input, standard output, and ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Perl, 2nd Edition

Mastering Perl, 2nd Edition

brian d foy
Learning Perl, 7th Edition

Learning Perl, 7th Edition

Randal L. Schwartz, brian d foy, Tom Phoenix
Perl in a Nutshell, 2nd Edition

Perl in a Nutshell, 2nd Edition

Nathan Patwardhan, Ellen Siever, Stephen Spainhour

Publisher Resources

ISBN: 9781449311063Errata PageSupplemental Content