develooper Front page | perl.perl5.porters | Postings from June 2008

Generic system() replacements (was Re: This Week on perl5-porters- 1-6 June 2008)

Thread Previous | Thread Next
Paul Fenwick
June 17, 2008 01:21
Generic system() replacements (was Re: This Week on perl5-porters- 1-6 June 2008)
Message ID:
G'day Jan / p5p,

Jan Dubois wrote:

> In addition to being somewhat slow (which most of the time may not
> be an issue), these helper processes want to execute $^X, which may
> not even be available if you are running a Perl program packaged
> into a self-contained executable with PAR/PerlApp/Perl2Exe.
> Therefore IPC::Run isn't really the generic system() replacement.


Although IPC::System::Simple *does* try to be the generic system() 

* Same calling syntax and semantics as CORE::system

* On Win32 it uses Win32::Process to try and spawn additional processes, 
which I understand to be quite fast.

* Multi-arg system() never invokes the shell under Win32, even though 
CORE::system will.

* Returns the exit value of the process (the full 16 bits on Windows), 
rather than requiring pain and suffering with $?.

* Provides a multi-args version of backticks which also doesn't invoke the 

* Has no dependencies outside of the core modules, and Win32::Process on 

* Does not depend upon $^X or other external commands, and so works fine in PAR.

* Provides well-formatted error messages, including exit status, signal 
number, signal name, and detailed of tainted data where applicable.

* Pure Perl.

* Works all the way back to 5.6.x.

The big difference in semantics is that IPC::System::Simple throws an 
exception if it spots something going wrong, whereas system() will require 
the programmer to dig through $? to try and find it.  I know which one I'd 
prefer. ;)


Anyway, I think that's enough self-promotion for now.  ;)



Paul Fenwick <> |
Director of Training                   | Ph:  +61 3 9354 6001
Perl Training Australia                | Fax: +61 3 9354 2681

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About