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).
In reply to Re^3: How to run a Perl script from another script?
by graff
in thread How to run a Perl script from another script?
by bradcathey
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |