I am working on a project, which involves many different script files. I would like to be able to have a file that is required (or of some sorts to make it work) so that it is basically a list of scalars, arrays and hashes (all of the basic built-ins) that allows me to setup a 'Configuration' of the system I am working on. I have read the document on Lexical Scoping and partially through have found that the part where requiring lextut1.pl which has $foo defined in another file is partially incorrect. I have in cases used this sort of require to do exactly what I am talking about.
The problem? Well the problem is this. When I use strict to make sure that I am not doing something utterly ignorant, it complains about $foo not being declared. Here is a basic code example.
# file: conf.pl
$foo = 'bar';
# file: script.cgi
#!/usr/bin/perl
use strict;
require 'conf.pl';
{
...
print $foo;
...
}
#
Simple I know, but this is the sort of usage that I am looking for. The only problem, is strict screams about the variable not being declared. Although, if you actually remove strict, this works.
However, I would like to use strict. Has anyone else considered this type of problem? Has there ever been a good solution to this?
Any help in this matter would be greatly appreciated.
Thanks,
Matt (mhorner)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.