Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

how to call perl-cgi from another perl-cgi?

by lucknesh (Initiate)
on Nov 07, 2006 at 06:11 UTC ( #582571=perlquestion: print w/replies, xml ) Need Help??

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

This node falls below the community's threshold of quality. You may see it by logging in.
  • Comment on how to call perl-cgi from another perl-cgi?

Replies are listed 'Best First'.
Re: how to call perl-cgi from another perl-cgi?
by holcapek (Sexton) on Nov 07, 2006 at 09:48 UTC
    Can you access "only" the URL of the second CGI script or oven the script itself (on the filesystem)?

    In the first case, you should call that script using LWP::UserAgent within the body of the first script, and then parse the output of HTTP response.

    In the latter case, you can call the second script using system functionlike this:
    system "script2.cgi arg1=val1 arg2=val2 var3=val3"

    Depending on what you're trying to achieve, you might also consider using more powerful tools like SOAP::Lite.
Re: how to call perl-cgi from another perl-cgi?
by izut (Chaplain) on Nov 07, 2006 at 10:41 UTC

    Maybe you want to be more specific about your need. You might want to create a module for the code contained in your perl2.cgi file. Something like that (untested):

    MyModule.pm:

    package MyModule; sub something { my ($param) = @_; # do something here } 1;

    perl1.cgi:

    use MyModule; use CGI; # process something here... my $result = process_something_here(); MyModule::something($result);

    perl2.cgi

    use MyModule; use CGI; # process other thing here... my $result = process_other_thing_here(); MyModule::something($result);

    Maybe you have to think about your problem. Maybe you want to share a specific part of your perl2.cgi file. If you want that, create a module (perlmodlib) and share that. It is better than glueing a lot of CGI's together.

    Hope that helps.

    Igor 'izut' Sutton
    your code, your rules.

Re: how to call perl-cgi from another perl-cgi?
by davorg (Chancellor) on Nov 07, 2006 at 10:43 UTC

    If the other program you need to call is really a CGI program then you should look at WWW::Mechanise.

    --
    <http://dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

Re: how to call perl-cgi from another perl-cgi?
by andyford (Curate) on Nov 07, 2006 at 10:58 UTC
    Another possibility is that you might want to make the two cgi's be alternate execution paths of one big cgi. In this case, they become "runmodes" of CGI::Application.

    andyford
    or non-Perl: Andy Ford

Re: how to call perl-cgi from another perl-cgi?
by xorl (Deacon) on Nov 07, 2006 at 16:18 UTC
    Would somthing like this work...
    ## This is perl1.cgi ## lots o' code goes here require (perl2.cgi);

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://582571]
Approved by planetscape
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2021-04-18 23:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?