in reply to Syntax details with "system"
I think the other posters roughly said it already, but I'll elaborate a bit from a systems programming standpoint.
system($str) is equivalent, OS-wise, to forking, and then exec'ing sh -c "$str"
system(@list) is equivalent to forking, setting ARGV to @list, and exec'ing the first item in @list.
In the latter form, there is no shell involved, which means one fewer fork (more efficient), no need to think about escaping things for the shell (wonderful), and that it is a bit safer against untrusted input. On the downside, you cannot use shell features such as redirection or pipes.
You are free to test what happens if you call this small perl script, let's call it showargs.pl with both styles:
#!/usr/bin/perl use Data::Dumper; print Dumper(\@ARGV);
Calling it with the following snippet, what do you expect the output to be? What about without the list-form invocation?
system 'showargs.pl', 'lens', '-n', "\"source $qscript; test_model $arguments\"", ">$output_file", "2>$logfile";
|
|---|