English 中文(简体)
How do I call another Perl CGI script within a CGI script?
原标题:
  • 时间:2009-11-24 11:44:22
  •  标签:
  • perl
  • cgi

I have a Perl CGI script that creates a login screen, i.e. user name and password.

I want, after successful login, the user to be redirected to the next action within the application (another Perl CGI script).

What is the command to redirect one CGI script or to an HTML page?

最佳回答

An example using CGI as David Dorward mentions.

use CGI;

if (redirect_needed) {
    # If redirect is desired, don t print headers...
    print CGI->redirect("http://some.other.url/");
    exit; 
}

# If no redirect is desired...
print CGI->header();
# etc...
问题回答

In HTTP terms you should have your program output a 302 or 303 status code and a Location header.

If you are using CGI.pm then you can use the redirect method to achieve this.





相关问题
Why does my chdir to a filehandle not work in Perl?

When I try a "chdir" with a filehandle as argument, "chdir" returns 0 and a pwd returns still the same directory. Should that be so? I tried this, because in the documentation to chdir I found: "...

How do I use GetOptions to get the default argument?

I ve read the doc for GetOptions but I can t seem to find what I need... (maybe I am blind) What I want to do is to parse command line like this myperlscript.pl -mode [sth] [inputfile] I can use ...

Object-Oriented Perl constructor syntax and named parameters

I m a little confused about what is going on in Perl constructors. I found these two examples perldoc perlbot. package Foo; #In Perl, the constructor is just a subroutine called new. sub new { #I ...

Where can I find object-oriented Perl tutorials? [closed]

A Google search yields a number of results - but which ones are the best? The Perl site appears to contain two - perlboot and perltoot. I m reading these now, but what else is out there? Note: I ve ...

热门标签