It seems your commands are broken, and you're spending effort trying to fix them at run-time. foo ; cd bar should be cd bar ; foo. You should fix your data before running your program, or at least separately from trying to execute them.

Why is a check.pl dying from SIGINT with no coredump considered successful? Why is a check.pl dying from SIGINT with coredump considered unsuccessful? While is running a program successfully considered an error? You're probably killing the program when you should be closing its input stream with Ctrl-D (default for unix) or Ctrl-Z (Windows).

You're printing $! when its meanlingless. You're not printing $? when its meanlingful.

You are using a C-style loop when a Perl-style counting loop would be simpler. In fact, you are using a C-style loop when a foreach loop would be ideal.

@run is both misnamed (it doesn't contain a run) and incorrectly pluralised (it s singular yet it contains multiple of what it contains).

Basically, that whole snippet should be:

for my $cmd (@cmds) { system($cmd) die("<$cmd>: Can't spawn: $!\n") if $? == -1; die("<$cmd> died from signal ", ($? & 0x7F), "\n") if $? & 0x7F; die("<$cmd> exited with code ", ($? >> 8), "\n") if $? >> 8; }

Everything extra is you trying to fix bugs made elsewhere, bugs better fixed elsewhere since fixing those bugs have nothing to do with executing commands.


In reply to Re: looking for suggestion!!! by ikegami
in thread looking for suggestion!!! by Sun751

Title:
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, details, 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, summary, 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.