On Fri, 29 Oct 2004 13:36:00 -0400 (EDT), Chris Devers <[EMAIL PROTECTED]> wrote: > On Fri, 29 Oct 2004, Jenda Krynicky wrote: > > > Actually no. They are generaly not very fast. The reason is that the > > shell interpreter needs to create a new process for each and every > > commend you specify in the script [...] > > Is this true even for built in shell commands? For example, commands > like cd, echo, export, kill, test, etc are all built in to Bash -- does > an external process run whenever you invoke one of these? > > -- > Chris Devers > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > >
It depends on the complexity of the command, and the syntax it is invoked with. It's complicated, but in general "system" spawns a subshell when called with a single argument, and does not call a subshell when called with multiple arguments, unless the shell function called is very simple, in which case even the single-argument call is handled by perl. It's important to remember also that the arguments are the number of arguments you give to the "system" function, not the arguments you supply for whatever shell command you're calling. so: system "ls /usr/bin" # simple, no subshell system 'lsof -u $PID | grep perl' # complicated, shell probably spawned system ("ls", "-l", $mydir) # multiple arguments, subshell not spawned. I hope this helps. -jay savage -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>