dirtdart has asked for the wisdom of the Perl Monks concerning the following question:

I have written the following module to hold configuration constants for a program I am writing.
#!/usr/bin/perl -w package SFConfig::Globals; use strict; use Exporter; use vars qw(@ISA @EXPORT); @ISA = qw(Exporter); @EXPORT = qw(TEMPLATE_DIRECTORY); sub TEMPLATE_DIRECTORY () {"/srv/www/vhosts/spamfilter.o +nlineky.net/Templates"} 1;
I would like to use these constants in the rest of my programs like so:
#!/usr/bin/perl -w use strict; use SFConfig::Globals; print "Content-type: text/html\n\n"; my $test = SFConfig::Globals::TEMPLATE_PATH; print "$test\n";
Whenever I run the script above on my Suse Linux 10.2 box with Perl 5.8.8 installed, I get the message "Bareword "SFConfig::Globals::TEMPLATE_PATH" not allowed while "strict subs" in use". When I run the exact same code with the exact same module on my Windows XP box with ActivePerl, it works just exactly as I would expect, printing the contents of TEMPLATE_PATH. On both machines, I saved the module in the site_perl directory. What else could I be doing wrong?

Replies are listed 'Best First'.
Re: Errenous behavior from Exporter
by Fletch (Bishop) on Nov 06, 2007 at 14:28 UTC
      I knew as soon as I posted this question that I would have done something stupid like that. Sorry to have bothered everyone.
Re: Errenous behavior from Exporter
by Anonymous Monk on Nov 06, 2007 at 15:23 UTC
    If you're going to export TEMPLATE_DIRECTORY, use it
    #!/usr/bin/perl -w use strict; use SFConfig::Globals; print "Content-type: text/html\n\n"; print TEMPLATE_DIRECTORY, "\n";