Andreas Schiffler wrote:
> 
> Hi,
> 
> I seem to have an odd problem with variable setup and use. The platform
> is apache/mod_perl as per LinuxMandrake 7.1.
> 
> Here is the setup:
> 
> A) I have a configuration.pm with variable declarations and no "use
> strict" similar to this:
> 
> ...
> @array=()
> ...
> %hash=()
> ...
> 
> B) Then I have a library of common routines that make use of these
> variables. These include routines to fill these variables with data.
> 
> sub fill_array();
> sub fill_hash();
> 
> C) Now in startup.pl is "use" both packages and call the fill_xyz()
> routines.
> 
> D) In the mod_perl scripts (the guts of these scripts is again in a
> package that gets called by a wrapper .pl script) I "use" both packages
> and make use of the data with $value=$configuration::array[] and
> $value=$configuration::hash{} ... just reading their values.
> 
> The Problem:
> The array is filled. The hash is empty.
> 
> Any ideas? Workarounds? Tests?

You didn't include enough code here for me to see what you're doing
wrong, but your variable assignments look fishy.  Here's a sample of how
to do it:

package SiteConfig;
%hash  = (
           'name'  => 'value',
           'name2' => 'value2',
         );

# in startup.pl
use SiteConfig ();

# in your module
my $value2      = $SiteConfig::hash{'name2'};
my $entire_hash = %SiteConfig::hash;
my $hash_ref    = \%SiteConfig::hash;

- Perrin

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to