DESCRIPTION

System::Sub provides in your package a sub that wraps the call to an external program. The return value is line(s) dependending on context (wantarray).

This may be what you need if you want to run external commands as easily as from a Unix shell script but with a perl-ish feel (contextual output). So this is not a universal module for running external programs (like IPC::Run) but instead a simpler interface for a common style of external programs.

System::Sub may be useful if:

you want to run the command synchronously (like system or backquotes)

the command

- is non-interactive (all the input is fed at start)

- input is @ARGV and STDIN

- output is STDOUT

- the exit code is what matters for errors

- STDERR will not be captured, and will go to STDERR of your program.

The underlying implementation is currently IPC::Run, but there is no garantee that this will stay that way. IPC::Run works well enough on both Unix and Win32, but it has its own bugs and is very slow.

IMPORT OPTIONS

Options can be set for the sub by passing an ARRAY just after the sub name on the use System::Sub line.

SEE ALSO

TRIVIA

I dreamed about such a facility for a long time. I even worked for two years on a ksh framework that I created from scratch just because at the start of the project I didn't dare to bet on Perl because of the lack of readability of the code when most of the work is running other programs.

After that project I never really had the need to run the same command in many places of the code, and in many different ways. Until I had the need to wrap Git in the release script of my github-keygen project. I wrote the first version of the wrapper there, and quickly extracted it as this module. So, here is it!