system

systemPATHNAMELISTsystemLIST
This function executes any program on the system for you and
returns that program’s exit status—not its output. To capture the output
from a command, use backticks or qx//
instead. The system function works
exactly like exec, except that
system does a fork first and then, after the exec, waits for the executed program to
complete. That is, it runs the program for you and returns when it’s
done, whereas exec
replaces your running program with the new one, so
it never returns if the replacement succeeds.
Argument processing varies depending on the number of arguments,
as described under exec, including
determining whether the shell will be called and whether you’ve lied to
the program about its name by specifying a separate
PATHNAME.
Because system and backticks
block SIGINT and SIGQUIT, sending one of those signals (such as
from a Control-C) to the program being run doesn’t interrupt your main
program. But the other program you’re running does
get the signal. Check the return value from system to see whether the program you were
running exited properly.
@args = ("command", "arg1", "arg2");
system(@args) == 0
|| die "system @args failed: $?"The return ...
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