in reply to Calling script from SSI or CGI
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.use strict; use CGI; my $cgi = new CGI; print $cgi->header(); body(); 1; sub body { ... }
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.
|
|---|