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

Hello fellow Monks,

Does anyone know how to call a Perl script from another Perl script, with parameters, on a web server?

For example, I tried:

system("perl /path/to/scipt.pl?parameter=xyz");

But the paramater does not get passed.

Any ideas?

Thank you!

  • Comment on call a Perl script from another Perl script, server-side, with parameters
  • Download Code

Replies are listed 'Best First'.
Re: call a Perl script from another Perl script, server-side, with parameters
by merlyn (Sage) on Dec 27, 2009 at 03:45 UTC
    Yes. Don't confuse CGI with command line. If your second script expects to be called as a CGI script, do that. Or else simulate everything that the webserver does to call a script (not trivial).

    -- Randal L. Schwartz, Perl hacker

    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

Re: call a Perl script from another Perl script, server-side, with parameters
by bobr (Monk) on Dec 27, 2009 at 12:13 UTC
    In case script.pl is using CGI module, you can use call from command line to set proper params - note the space between script name and query string:
    system("perl /path/to/scipt.pl ?parameter=xyz");
    -- Roman