On Thu, Jun 11, 2009 at 11:47, Tech W.<tech...@yahoo.com.cn> wrote:
snip
> system "command","-a","-b","-c";
snip

In this case Perl runs command directly

snip
> system "command -a -b -c";
snip

In this case Perl runs the default shell for the OS and has it run command.

snip
> and, which is better?
snip

Depends on what you are doing.  In general, the first is better
because it does not have to spawn a third process and the shell can't
mess with your arguments; however, if you want shell expansion you
need to use the second form:

system "do_something *.txt";

Of course, you can say

system "do_something", glob("*.txt");

But if you want to do something complicated like

system "somecommand | grep foo | othercommand | thirdcommand";

it gets a lot more complicated to do in Perl.

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to