Re^2: Modules which improve system() ?by pjf (Curate)
|on Jun 26, 2006 at 04:29 UTC||Need Help??|
Firstly, let me say how appreciative I am that you're willing to go forth and write new modules when the need is shown. Unfortunately, your module leaves me in somewhat of a dilemma. It's close in principle to what I want, and almost, but not quite, satisifies what I need.
My motivation for the module is very specific. I want to make it easier and simplier to do the right thing, than it is to do the wrong thing. Presently, doing the wrong thing is easy:
This doesn't do any sort of error checking, and so is a great spot for a bug to hide. Using IPC::Run::Simple for the basic case does make it easier:
use IPC::Run::Simple qw(:Fatal);
However for the next most simple case, it suddenly much longer, and not as simple:
I sill feel it provides a simplier interface for this module to get rid of named arguments entirely:
my $exit_value = run([0, 1, 5], "some_command");
especially as that makes it easy to modify an existing (single-argument) line to allow new exit values.
My other big concern is that run() does not throw exceptions by default, which means the developer has to remember to do extra work in order to do the right thing (either with :Fatal, or by using or die).
It may seem that I'm being incredibly nit-picky, but I'm really trying to make a module that's as fool-proof as can possibly be. I want the default choice to be the right choice even if the developer is ignorant, slack, doesn't read the documentation, and possibly doesn't even understand Perl. Think of your sysadmin archiving files before deleting them. You want that script to die if the archive fails.
Yes, for me "doing the right thing" == "throwing an exception". Damian discusses this extremely well on pages 274-278 of Perl Best Practices.
Having said all that, I really want to avoid the CPAN having two modules that do almost the same thing. Goodness knows we have enough of that already.
I'd very much appreciate further discussion on this topic, and I would love to hear your thoughts.
All the very best,
Perl Training Australia