rsennat has asked for the wisdom of the Perl Monks concerning the following question:

hi all,

how do i run several perl scripts from a single perl script in sequence??

thanks
rsennat

Replies are listed 'Best First'.
Re: run several scripts in sequence
by graff (Chancellor) on Jan 03, 2006 at 07:10 UTC
    There are a couple different ways, which you should read about:
    • a series of "backtick" statements (a.k.a. the "qx" operator) -- look for "qx" under "quote-like operators" in the "perlop" man page ("perldoc perlop").
    • a series of "system()" calls -- look up the "system" builtin function ("perldoc -f system").
    The differences between those two might not matter for your particular needs, but you should read about them anyway.
Re: run several scripts in sequence
by astroboy (Chaplain) on Jan 03, 2006 at 09:05 UTC
    This may or may not be appropriate to your needs:
    #!/usr/local/bin/perl do "script1.pl"; do "script2.pl";
    "do" effectively evals the contents of your files. Require makes sure that you don't include the same file more than once:
    #!/usr/local/bin/perl require "script1.pl"; require "script2.pl";
    Just be careful - you may end up bringing some variables into your namespace Script 1:
    #!/usr/local/bin/perl use strict; $a = 1;
    and your master code:
    #!/usr/local/bin/perl use strict; do "script1.pl"; do "script2.pl"; print $a;
    Of course, you may wish to bring some config settings in this way, but you'd be playing with fire IMHO. Wrapping your scripts in a package will prevent namespace leakage
Re: run several scripts in sequence
by tirwhan (Abbot) on Jan 03, 2006 at 07:11 UTC

    Hmm, I get the feeling you should elaborate a little more. The answer to your question is just call them one after the other with system or backticks or open, as long as you don't background any process they will be called sequentially (i.e. one after the other) and each process will complete before the next one is started. Is that what you are trying to do?


    A computer is a state machine. Threads are for people who can't program state machines. -- Alan Cox
Re: run several scripts in sequence
by idsfa (Vicar) on Jan 03, 2006 at 18:37 UTC

    You have asked this before, but still have not taken any effort to help us help you. Please read and answer some of the questions posed to you.


    The intelligent reader will judge for himself. Without examining the facts fully and fairly, there is no way of knowing whether vox populi is really vox dei, or merely vox asinorum. — Cyrus H. Gordon