[ Please do not top-post! ]

Xiangli Zhang wrote:
Gunnar Hjalmarsson wrote:
Xiangli Zhang wrote:
I am trying to redirect from cgi1(with one string variable say
$str with value from its calling parent html form) to cgi2, I
know I can use redirect function of CGI model to implement
redirection.

But i don't know how to pass $str to cgi2 from cgi1.

If you print a "Location" header (with or without CGI.pm's redirect() function), you can pass the string as a query string. But if cgi2 is another Perl program, using the require() function may be a better alternative.

Anyone know example how to use "require" function passing string variable?

You don't pass it at all. Just make it a package global.

cgi1.pl
----------------------------------------------------
#!/usr/bin/perl
use strict;
use warnings;
use CGI 'param';
our $str = param('somestring');
require 'cgi2.pl';
----------------------------------------------------

cgi2.pl
----------------------------------------------------
#!/usr/bin/perl
use strict;
use warnings;
use CGI ':standard';
print header();
print $::str;
----------------------------------------------------

See "perldoc perlmod".

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to