I would like to run some command (e.g. command
) using perl\'s system()
. Suppose command
is run from the shell like this:
As with everything in Perl, there's more than one way to do it :)
The best way, Pass the arguments as a list:
system("command", "--arg1=arg1","--arg2=arg2","-arg3","-arg4");
Though sometimes programs don't seem to play nice with that version (especially if they expect to be invoked from a shell). Perl will invoke the command from the shell if you do it as a single string.
system("command --arg1=arg1 --arg2=arg2 -arg3 -arg4");
But that form is slower.