-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Bram x schrieb:
|> From: Tom Schindl <[EMAIL PROTECTED]>
|>
|> -----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
|
|
| Thank you, indeed, if I use do(), it works good. I'll read perlfunc.
|
Better you'd do the following:
main.pl:
- --------------------------8<--------------------------
use CGI;
my $lang = $cgi->param('lang');
require "$lang.pl";
my %vars = "i18n::$lang"->getVars();
- --------------------------8<--------------------------
nl.pl:
- --------------------------8<--------------------------
package i18n::nl;
my %vars = ( lang => 'nl' );
sub getVars {
~ return %vars;
}
1;
- --------------------------8<--------------------------
en.pl:
- --------------------------8<--------------------------
package i18n::pl;
my %vars = ( lang => 'nl' );
sub getVars {
~ return %vars;
}
1;
- --------------------------8<--------------------------
| _________________________________________________________________
| 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
iD8DBQFCwSYWkVPeOFLgZFIRAkwAAJ43XdQa324yFy3NhYaa91JZFAmYewCgn9ZV
1GiBNBfgTcS3uRZV5kKFrbc=
=/dbO
-----END PGP SIGNATURE-----