in reply to Re: How to run a Perl script from another script?
in thread How to run a Perl script from another script?

graff, I appreciate your candor. The reason is that new script is really the more weighty script, basically a full-fledged "program" that I have a hard time thinking of as a merely module. There truly is a transfer of purpose and direction when leaving the one earlier script and going to the new script.

Hope that helps.


—Brad
"Don't ever take a fence down until you know the reason it was put up." G. K. Chesterton
  • Comment on Re^2: How to run a Perl script from another script?

Replies are listed 'Best First'.
Re^3: How to run a Perl script from another script?
by graff (Chancellor) on Oct 05, 2004 at 01:58 UTC
    ... that new script is really the more weighty script, basically a full-fledged "program" that I have a hard time thinking of as a merely module.

    Do you mean that sometimes this new script is run entirely by itself, without any prior script being run ahead of it? I wasn't expecting this... Based on the initial question, I assumed that you have several scripts that each produce some distinct beginning portion of a page, and the "newscript" provides a common final portion for all those different pages. If that's what you're doing, then it still seems more sensible as a module, regardless of its size.

    (On the other hand, if the script really does work on its own without any prior script ahead of it, I'm a little unclear about how you are adapting it to this "secondary" role.)

    Do you have some different reason for "chaining" scripts in this way?

    Turning a script into a module doesn't need to involve a lot of fuss. Just put in a "package" statement at the top and a "1;" at the end, and instead of printing to STDOUT, have it accumulate text into a return string. Maybe you'll need a little bit of "reorganization" to have a single sub that returns the string (by doing whatever "main" does in the current version).

      Yes, it is run on it's own, depending on circumstances.


      —Brad
      "Don't ever take a fence down until you know the reason it was put up." G. K. Chesterton