Summary of Process Operations
Table 14.1 summarizes the operations that you have for launching a process.
Table 14-1. Summary of Subprocess Operations
|
Operation |
Standard Input |
Standard Output |
Standard Error |
Waited for? |
|---|---|---|---|---|
system() |
Inherited from program |
Inherited from program |
Inherited from program |
Yes |
|
Backquoted string |
Inherited from program |
Captured as string value |
Inherited from program |
Yes |
|
|
Connected to filehandle |
Inherited from program |
Inherited from program |
Only at time of |
|
|
Inherited from program |
Connected to filehandle |
Inherited from program |
Only at time of |
|
|
Not implemented |
Not implemented |
Not implemented |
Not implemented |
The simplest way to create a process is with the
system function. Standard input, output, and error
are unaffected (they’re inherited from the Perl process). A
backquoted string creates a process, capturing the standard output of
the process as a string value for the Perl program. Standard input
and standard error are unaffected. Both methods require that the
process finish before any more code is executed.
A simple way to get an asynchronous process (one that allows the Perl program to continue before the process is complete) is to open a command as a filehandle, creating a pipe for the command’s standard input or standard output. A command opened as a filehandle for reading inherits the standard input and standard ...
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.
Read now
Unlock full access