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


In reply to Re: another CGI question ... passing values to another script by tlm
in thread another CGI question ... passing values to another script by Angharad

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.