perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tom Schindl <tomAtLi...@gmx.at>
Subject Re: Declaring variables in a required script
Date Tue, 28 Jun 2005 07:19:40 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You should learn how perl works. I suppose you are running the script as
an Apache::Reqistry but you miss the version.

You problem is that if en.pl is loaded using require in a process is
will not be reloaded once more hence you lines of code won't be run.

If you really want to run the "required" code everytime you are loading
it you have to use "do" see perlfunc for more information. Still I'd
consider using "do" a bad program design.

Tom

x x schrieb:
| I'm sorry if this question has already been answered, but I couldn't
| find the answer.
|
| Here is my problem. I have a script that looks like this:
| #!/usr/local/bin/perl -Tw
|
| use strict;
| use CGI;
|
| my $q = new CGI;
|
| my $var = $q->param("var");
| $var =~ m/(.*)/; #just to don't get any tainted errors, don't use in
| public.
| $var =  $1;#just to don't get any tainted errors, don't use in public.
|
| require "/Library/WebServer/mod_perl/$var.pl";
|
| print "Content-Type: text/plain\n\n";
|
| print "1\n" if $lang::varl eq $var;
| print "$var\n";
| print "$lang::varl\n";
|
|
|
| And I have the script nl.pl:
| #!/usr/bin/perl -wT
|
| use strict;
|
| $lang::varl = "nl";
|
|
|
| And the last one, en.pl:
| #!/usr/bin/perl -wT
|
| use strict;
|
| $lang::varl = "en";
|
|
| So if I make a request a few times with &var=en and then switch to
| &var=nl It sometimes happens that I get:
| nl
| en
|
| So I don't get the 1 ($lang::varl and $var don't eq) and indeed the two
| lines don't match ("en\nnl" or also sometimes "nl\nen") $var always has
| the right value, the problem is that $lang::varl doesn't always have the
| right value.
|
| I am using Apache 1.3.33, mod_perl 1.29 and Mac OS X 10.4.1.
|
| I hope someone could help me. Thank you very much!
|
| Bram.
|
| _________________________________________________________________
| Direct antwoord op je vragen: gebruik MSN Messenger
| http://messenger.msn.nl/
|
|

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCwPoLkVPeOFLgZFIRAuKDAKCFGY5qJZmdK7onl+AaD9icsPYH8gCgsTjw
fmldKQYXB1yBvh6s/7INRjw=
=Y1qX
-----END PGP SIGNATURE-----

Mime
View raw message