RE: A ghost in the machine?

"Ihnen, David" <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <0C4F9AE61E425F4F8C6912AF90E9A9E9C645E738@EX-SEA19-B.ant.amazon.com>
Global?  There's no need to use a global here.   You only ever reference %CFG *in* the package... so just make it package scoped - it'll act like a static variable and persist.  (scope it with 'my' and remove it from the export)

You can always get the value you want with a call to MyConfig::cfg

David

-----Original Message-----
From: Tosh Cooey [mailto:[email protected]] 
Sent: Thursday, January 14, 2010 10:45 AM
To: [email protected]
Subject: A ghost in the machine?

Hi to everyone!

I'm trying to find out if I'm passing objects properly under mod_perl 
because something is not working as I expect.

index.pl
########
use MyConfig;
my $vars = { config => &cfg };


MyConfig.pm
###########
package MyConfig;

use strict;
use Exporter;
use vars qw(@ISA @EXPORT %CFG );
use ClientConf;
@ISA = qw(Exporter);
@EXPORT = qw(%CFG &cfg);

%CFG = { global vars... };

sub cfg {
   my $CFG{$clientID} = new ClientConf;
   return $CFG{$clientID};
}
1;


Under normal PERL $vars->{config} is a MyConfig object.  Under mod_perl 
nothing is returned.  Debugging with "print" statements in &cfg shows me 
that "ref $CFG{$clientID}" is ClientConf, the object is there, but upon 
return it just disappears.

I have other functions which "return new MyUser()" and these work 
perfectly, so I'm thinking that the problem lies with the global 
variable "$CFG" and that something which I think should be happening is 
NOT happening.

I'm flummoxed...

Thank-you for any insights!

Tosh

-- 
McIntosh Cooey - Twelve Hundred Group LLC - http://www.1200group.com/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.