in reply to STDOUT and STDIN question

Using do means that script1.pl etc. all run in the same process space as masterscript.pl. (Is this intended? Any leftover variables from one script will leak over to the next.) This means you can dup STDOUT and STDERR before running the various scripts, which is only half a solution so far. Before proceeding, is this what you want to do?

Replies are listed 'Best First'.
Re^2: STDOUT and STDIN question
by Anonymous Monk on Nov 03, 2004 at 14:47 UTC
    Yeah, it was intentional to run the scripts with the do command, are you saying that there may be advantages to running the scripts with a system command instead?
    Also, I'm fairly new to perl, so I don't understand what you mean when you say I can dup STDOUT and STDERR

    Thanks for your quick response though
    Jonathan
      Yes, do is a bit less useful than two different appoaches: modules, and completely separate scripts.

      If your child scripts have any code in common with each other, and especially if they can share resources (files, data), it makes sense to write a module for each, and let everything run in equal standing in the same process. If, however, you want each task to really be a separate script, don't risk lefover values leaking over, and have the master invoke each script in a completely separate process.

      (You can still share code by using modules if you run separate processes, of course: simply have them use the common code.)

      As for duping, you can copy -- dup -- a filehandle over. perlopentut has details. It doesn't finish solving your original problem but it might help; alternatively pg's suggestion might be a better route.