what you need in your config file is something like the following:
### config.pm ###
%hash = ( foo => 'bar' );
1; #return a true value for 'use'
in your script, you'll need to do this:
### script.pl ###
use strict;
use 'config.pm';
use vars qw(%hash);
and then strict wont complain about lack of package indication...
now, what you *really* want to do is package the config file and use exporter to
make sure you don't clobber namespaces, but that might be a bit advanced, so for
now, this should solve your problem
hope this helps,
Jos Boumans
Dianne Van Dulken wrote:
> Hi all,
>
> I was (yet again) hoping someone might help me with something.
>
> I have a cfg file called extra_details.cfg containing a hash %my_hash.
>
> I reference this in my perl script, using a require "extra_details.cfg"
>
> The problem now is that every time I try to reference my_hash in my script,
> whilst I am using strict, I get a
> Global symbol "%my_hash" requires explicit package name error.
>
> If I add an "my %my_hash;" anywhere, it overwrites the hash, so it is just a
> blank one.
>
> Does anyone know how I can get around this?
>
> It will work perfectly if I remove the "use strict" line, but I have these
> terrible qualms of guilt and fear every time I do so.
>
> Thanks
>
> Di
>
> --
> Dianne van Dulken
> E-commerce Analyst/Programmer
> OzEmail
> Phone: (02) 9433 2510
>
>