You're right, it's fine. If it works, I'd be disinclined to fix it. If there were a lot more than 20 or so scripts in the "run_me" directory, I might be inclined to save myself the overhead of launching that many sub-shells to run that many processes -- something like this is an easy patch (if you have a unix-like system):
open SH, "| /bin/sh" or die "can't launch subshell: $!"; for my $file ( @files ) { my $cmd = "perl -Ilib $file >> log\n"; print STDERR $cmd; print SH $cmd; # stderr from subshell will go to STDERR } close SH;
update: Since all the processes are appending their stdout to the same log file, you could leave the ">> log" out of the sub-shell command lines, and run the main script like this (assuming a bourne-like shell that allows separate redirection of stdout and stderr):
$ run-em-all.pl > log 2> errlog
another update: Actually, the for loop shown above will tend to get it's own STDERR output mixed up wrong with any STDERR coming from the subshell. By default, output to SH will be buffered, and you're most likely to see all 20 or so command lines listed first, then if any of them caused problems, their STDERR output will come afterwards. Just imposing autoflush on SH will not solve the problem -- in fact, it could make it worse, since both the subshell and the main perl script could end up writining to STDERR at the same time -- what a mess.

Either don't echo the command lines to STDERR, or else log them this way (again, assuming a bourne-like shell):

$cmd = "echo running $file 1>&2; perl -Ilib $file" print SH $cmd;
This way, the subshell itself prints a message to stderr before running each little script file.

In reply to Re: running many small, similar scripts by graff
in thread running many small, similar scripts by qq

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.