wgriffin has asked for the wisdom of the Perl Monks concerning the following question:

I have a cgi perl script that gets invoked from the browser. The user completes a form. The script processes the form and if they filled in one of the fields, I want to call another program that will ask them some other questions and process their answer, updating a mysql database. Then return to the location of the first script where I left off and continue to process the data inputted.

Replies are listed 'Best First'.
Re: CGI Script calling another
by McDarren (Abbot) on Jan 07, 2008 at 03:25 UTC
    Sounds great!

    So... what have you done so far, and where exactly are you stuck?

    I guess you are probably looking for something as simple as:

    if (param('foo')) { # show extra form } else { # show original form }

    Cheers,
    Darren :)

Re: CGI Script calling another
by talexb (Chancellor) on Jan 07, 2008 at 04:00 UTC

    OK, so the magic word you want is 're-direct'.

    • First script runs; if .. they filled in one of the fields ..
      • Re-direct to the second script that asks some questions, and then ..
    • .. continue with the first script, having either called the second script, or not.

    Make sense?

    Alex / talexb / Toronto

    "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Re: CGI Script calling another
by bradcathey (Prior) on Jan 07, 2008 at 14:26 UTC

    Here's what talexb is referring to:

    use CGI qw/:cgi/; my $query = new CGI; if ($query->param('somefield') { print $query->redirect(-location=>'subsequent.pl'); }
    —Brad
    "The important work of moving the world forward does not wait to be done by perfect men." George Eliot