Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Berkeley Access through Apache request phases

by abaxaba (Hermit)
on Aug 03, 2004 at 03:51 UTC ( [id://379524]=perlquestion: print w/replies, xml ) Need Help??

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

How would I go about (either via tie or straight object instantiation) creating a BerekelyDB::Hash variable during PerlChildInitHandler, and then access it during PerlTransHandler? To Wit, my latest attempt:
in httpd.conf PerlSetVar streamDB "/adconfig/config" PerlSetVar clickDB "/adconfig/click" PerlChildInitHandler Config PerlTransHandler Serve
in Config.pm sub handler { my $r=shift; my $config=$r->dir_config('streamDB'); my $click=$r->dir_config('clickDB'); %CORE::GLOBAL::config = new BerkeleyDB::Hash -Filename => $config, -Flags => "DB_RDONLY" or die "Cannot open file $config: $!$BerkleleyDB::Error\n"; }
In Serve.pm sub handler { my $r=shift; unless (scalar(keys %CORE::GLOBAL::config)) { die ("no config data loaded"); } # Code Always dies }
I've got the requisite use statments and such in Config.pm, and have tried tied hashes, stashing hashrefs in pnotes and untied hashes, and am now at the end of my rope. Any thoughts?

ÅßÅ×ÅßÅ
"It is a very mixed blessing to be brought back from the dead." -- Kurt Vonnegut

Replies are listed 'Best First'.
Re: Berkeley Access through Apache request phases
by bageler (Hermit) on Aug 03, 2004 at 05:51 UTC
    I did this successfully between a content handler and a cleanup handler, the major difference is that I have both handlers in the same package thusly:
    sub conthandler { $r = shift; tie %CORE::GLOBAL::testdb, 'BerkeleyDB::Hash', -Filename => 'testdb', -Flags => 'DB_RDONLY' or die "cannot open bdb $!$BerkleleyDB::Error"; print join ',',keys %CORE::GLOBAL::testdb; $r->register_cleanup(\&cleanuphandler); } sub cleanuphandler { my $r = shift; die unless scalar keys %CORE::GLOBAL::testdb; # doesn't die }
Re: Berkeley Access through Apache request phases
by perrin (Chancellor) on Aug 03, 2004 at 15:39 UTC
    Putting it in CORE::GLOBAL:: isn't a very good idea. What was wrong with pnotes? That should work fine for this.
      post a working example for the OP? Obviously he couldn't get it to work.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://379524]
Approved by Zaxo
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-03-28 16:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found