in reply to another CGI question ... passing values to another script
The simplest thing would be to use system or one of its variants (backticks, exec, etc.). E.g. if your other CGI script is called foo.pl and it's implemented with CGI:
my $cgi_script = 'foo.pl'; my @args = qw( bar=baz quux=frobozz ); system( $cgi_script, @args ) == 0 or die "call to $cgi_script failed: $?";
But I think this is a fragile design. A better alternative would be to refactor the functionality of the script that you want to call into a function, and define a module around this function that the first script can load (with use or require or do). And once you do this refactoring, what used to be the "second" CGI script in this story would become a wrapper around the core module. You'd ultimately end up with two CGI scripts calling the same module.
Update: Modified the example code to more closely resemble an interaction with another CGI script, implemented using CGI (thanks to BUU for pointing out the omission of CGI.pm). Added explanatory remarks.
the lowliest monk
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: another CGI question ... passing values to another script
by BUU (Prior) on Jun 08, 2005 at 18:47 UTC | |
|
Re^2: another CGI question ... passing values to another script
by Angharad (Pilgrim) on Jun 08, 2005 at 17:45 UTC |