2006/11/15

Spawning other program in perl

1. Backtick:
`system call or other program `;
No standard output of system call/other program can be shown on the current standard output, but standard error will be shown.
You can use a variable to hold the standard output, and then print it out. For example:
$stand_out = `system call or other program`, print “$stand_out”;

2. System ( )
system (“system call/other program”)
Both standard output and standard error of system call/other program will be shown on the current standard output.
If you use:
$result = system (“system call/other program”)
You will get $result = 0, when there is no error in system call/other program, otherwise, you will get strange number like 256/-1.

No comments:

Post a Comment