In the script to be called, wrap as much as you can, save for printing the HTTP header, into a subroutine, call it body() for example This should be a unique function name. In that script file, your main routine should be something like:
use strict;
use CGI;
my $cgi = new CGI;
print $cgi->header();
body();
1;
sub body {
...
}
If you are comfortable with it, it's probably better to make this a small module at this point, though in some situations I don't think that is necessary.
In the script that you want to call this, simply now "include 'file.pl';" at the top, where file.pl is the script above, and where you want to include the output from that script, you can use "body();" there. Of course, if you make it a module, you'll need to do some other things.
There's a few little gotchas with variable inclusion and the like, but that's the general idea.
And if this body() will change directories, you can easily get the current working directory at the start of the sub, then restore that when you are done with the processing.
Dr. Michael K. Neylon - mneylon-pm@masemware.com
||
"You've left the lens cap of your mind on again, Pinky" - The Brain
| [reply] [d/l] |