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
From:
Paul Fenwick
Date:
June 17, 2008 01:21
Subject:
Generic system() replacements (was Re: This Week on perl5-porters- 1-6 June 2008)
Message ID:
485773D6.1050600@perltraining.com.au
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.

<hubris>

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

* 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 
shell.

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

* 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. ;)

</hubris>

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

Cheerio,

	Paul

-- 
Paul Fenwick <pjf@perltraining.com.au> | http://perltraining.com.au/
Director of Training                   | Ph:  +61 3 9354 6001
Perl Training Australia                | Fax: +61 3 9354 2681

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About