Exec another script in perl

Hi!

I have a script which is generating output from other files.
For example:

I have index.cgi which calls htmloutput1.inc and displays the HTML content of htmloutput1.inc.

It works with lines, that's the easy part. But when it comes to , how to do i get it to execute the cgi script?

The part index.cgi looks like this:

.
.
if($html =~ m//) {
$file = $1;
if($html =~ m/(.cgi)/) {

** How do I get it to execute the cgi file here? **

}
}
.
.

Please help me
regards Crille

Comments

  • There are a number of ways to do this, probly what your after is

    [code]
    system("script.cgi");
    [/code]

    This will send the output of 'script.cgi' to STDOUT, which will end up on the html page. Another way is

    [code]
    my $output = `script.cgi`;
    [/code]

    This does as above, but puts all output in $output, notice that the ` character is not a quote, it is a backtick which can be found under escape on most keyboards.

    The last way of doing it is

    [code]
    exec("script.cgi");
    [/code]

    This is the same as system except that with system the perl script will wait until script.cgi returns, exec will start the script and then carry on with itself.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories