qq has asked for the wisdom of the Perl Monks concerning the following question:
I've got about 20ish small scripts that need to be run. More are likely to be created.
They look like:
#!/usr/bin/perl use Some::Module; my $obj = Some::Module->new( %options, code => \&code ); $obj->do_some_work; sub code { ... }; # not always
Mostly its just the arguments to the constructor that differ, but occaisionally a coderef is passed in.
So these scripts all need to get run one after another. I've got something like:
my @files = glob( 'run_me/*' ); while ( my $file = shift @files ) { my $cmd = "perl -Ilib $file >> log"; print STDERR "$cmd\n"; system( $cmd ) == 0 or die "something wrong: $?\n"; }
This is fine, except that I've got a feeling that it could be prettier.
Should I cat all the small scripts together, thus saving the cost of starting perl for each, and the use Some::Module time? (They also each open a database connection and write to it, which could be done just once.) Should I cut down the small scripts to make them just be config files (maybe yes, but I'm not sure I've time left, or how to represent a couple of 'special cases').
Is there something else I've overlooked?
Thanks, qq
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: running many small, similar scripts
by graff (Chancellor) on Jun 13, 2004 at 23:54 UTC | |
by qq (Hermit) on Jun 14, 2004 at 00:55 UTC |