in reply to CGI and require
The problem is that variable declarations under use strict are checked at compile-time, but require isn't executed until run-time. So the variables aren't yet declared when your code is compiled, and they trigger an error.
The solution (apart from breaking this out into a module, as davido suggested) is to load the config file before the rest of your code is compiled. You can do this by loading it in a BEGIN block:
BEGIN { require 'config.pl'; }
Also, it may be that do 'config.pl' is what you really want; require will only load the config file once, even if you have several modules that are using it. do is closer to an eval, which is what I think of when I'm loading a config file.
|
|---|