On 5/23/06, siegfried <[EMAIL PROTECTED]> wrote:

How do I run a perl program from a perl program? I could use the back quote
(grave) I suppose. I could also use "system". Is there  a better way that
does not create an additional process?

I have six perl programs running once a day (via cygwin cron). I would like
to have a single cron job running once an hour that checks the database for
the oldest task and, if it is more than 24 hours old, run it.

I could also write one monster program that combines all six programs. That
is a lot of superfluous "use" statements if I'm only going to be running one
of the six at a time.

Perhaps I could have a "switch" statement to only "require" those modules
that have been determined to be necessary for the oldest task. Is this the
best way?


if it's a standalone script you want to run, use system() or `` if you
need to capture output.

if it's just a bunch of routines you want to execute, you could put
the main routine in the script into a  sub called from within your
wrapper script, including the library script with
require('/path/to/script.pl'); at the top. (no need for shebang line
here).

require('/path/to/foo.pl');

foo(); # call main::foo sub routine defined inside foo.pl




--
Anthony Ettinger
Signature: http://chovy.dyndns.org/hcard.html

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to