Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Re: Re: Running System Commans With ""

by jkahn (Friar)
on Sep 11, 2002 at 20:26 UTC ( #197067=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Running System Commans With ""
in thread Running System Commands With ""

Yes, it's faster because there's no need for an intermediate sh process to get loaded, parse the arguments, redirect input and output where they should be sent to, and pass the arguments to the program invoked.

If you do want shell-style redirection, though, you'll have to use a system EXPR syntax. It's not all bad; a number of Perl Cookbook recipes use it for good reason (mostly for shell redirection).

Replies are listed 'Best First'.
•Re: Re: Re: Re: Running System Commans With ""
by merlyn (Sage) on Sep 12, 2002 at 17:04 UTC
    Yes, it's faster because there's no need for an intermediate sh process to get loaded, parse the arguments, redirect input and output where they should be sent to, and pass the arguments to the program invoked.
    No, if there are no shell metachars, Perl does the splitting itself, so there's no sh process involved.

    Convince yourself of this by executing an appropriate ps command during each of

    system "sleep 5"; system "sleep 5;"; # notice the semicolon
    Other arguments in favor of "avoid the sh at all costs" in this thread are still valid. Just wanted to point out that the single-arg system does not always call sh. It just might.

    -- Randal L. Schwartz, Perl hacker

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://197067]
help
Chatterbox?
[choroba]: Perl to the rescue!
[Corion]: hippo: At least for the German translation, the wordplay is translated as well
[Discipulus]: always! but if i can ask choroba why you always use the inverted (to me) form 1 == $.?
[choroba]: To avoid accidental overwriting of the variable in if ($x = 3)
[karlgoethebier]: Corion: Auch in hessisch? Mer wasses net.
[Corion]: Hmm - I'm not sure, I haven't read the mundart/slang translations ;)

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (12)
As of 2017-05-24 08:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?