Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

G'day Steve,

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:

use IPC::Run::Simple qw(:Fatal); my $exit_value = run(command => "some_command", allowed => [ 0, 1, 5 ]);

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,

In reply to Re^2: Modules which improve system() ? by pjf
in thread Modules which improve system() ? by pjf

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others surveying the Monastery: (2)
    As of 2018-01-21 22:52 GMT
    Find Nodes?
      Voting Booth?
      How did you see in the new year?

      Results (230 votes). Check out past polls.