in reply to Re^2: Config file recommendations?
in thread Config file recommendations?

I think maybe you're looking for Exporter. With it, you can have a module that will place a variable into the namespace of a program that uses it.

Replies are listed 'Best First'.
Re^4: Config file recommendations?
by Spidy (Chaplain) on Mar 19, 2008 at 18:19 UTC

    This is what I've been trying, but it doesn't quite seem to work:

    use Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(%config); %config = ( foo => bar, baz => bat );

    But I would still get the error Global symbol "%config" requires explicit package name. The code to use my config file was:

    use config;

      Main file:

      use strict; use warnings; use lib '.'; use MyConfig; use Data::Dumper; print Dumper \%config;

      MyConfig.pm:

      package MyConfig; use strict; use warnings; use Exporter; our @ISA = qw(Exporter); our %config; our @EXPORT = qw(%config); %config = ( foo => 'bar', baz => 'bat', ); 1;

      And the output:

      $VAR1 = { 'baz' => 'bat', 'foo' => 'bar' };