start page | rating of books | rating of authors | reviews | copyrights

Book Home Programming PerlSearch this book

25.5. Interprocess Communication (IPC)

To maximize portability, don't try to launch new processes. That means you should avoid system, exec, fork, pipe, ``, qx//, or open with a |.

The main problem is not the operators themselves; commands that launch external processes are generally supported on most platforms (though some do not support any type of forking). Problems are more likely to arise when you invoke external programs that have names, locations, output, or argument semantics that vary across platforms.

One especially popular bit of Perl code is opening a pipe to sendmail so that your programs can send mail:

open(MAIL, '|/usr/lib/sendmail -t') or die "cannot fork sendmail: $!";
This won't work on platforms without sendmail. For a portable solution, use one of the CPAN modules to send your mail, such as Mail::Mailer and Mail::Send in the MailTools distribution, or Mail::Sendmail.

The Unix System V IPC functions (msg*(), sem*(), shm*()) are not always available, even on some Unix platforms.



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.