dmitri has asked for the wisdom of the Perl Monks concerning the following question:
Dmitri/Test.pm
package Dmitri::Test; INIT { # This does not work under Apache::Registry: *{"Dmitri::Test::ABC::say_hello"} = sub { print "hi\n"; }; *{"Dmitri::Test::ABC::new"} = sub { return bless {}, "Dmitri:: +Test::ABC" ; }; # This works: #sub Dmitri::Test::ABC::say_hello { print "hi\n"; }; #sub Dmitri::Test::ABC::new { return bless {}, "Dmitri::Test:: +ABC"; }; } sub say_hi { my $x = Dmitri::Test::ABC->new; $x->say_hello; } 1;
test.cgi
#!/usr/bin/perl -w use Dmitri::Test; print <<HTML; Content-type: text/plain HTML Dmitri::Test::say_hi; exit(0);
The code runs fine under mod_cgi. Using Apache::Registry, I get this error:
[Wed Nov 6 16:49:12 2002] [error] Can't locate object method "new" via package "Dmitri::Test::ABC" (perhaps you forgot to load "Dmitri::Test::ABC"?) at /usr/lib/perl5/site_perl/5.6.1/Dmitri/Test.pm line 14.
I could theoretically use the second method pointed out in Test.pm code, but the problem is that the routines are generated from code refs, and doing
sub A::B::routine { &$ref }
just causes me mental pain and anguish (inefficient).
I wonder if your collective wisdom could show me the way out of this problem. Many thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Apache::Registry losing subs created via globs.
by perrin (Chancellor) on Nov 06, 2002 at 22:23 UTC | |
by dmitri (Priest) on Nov 06, 2002 at 22:28 UTC | |
by runrig (Abbot) on Nov 06, 2002 at 22:46 UTC | |
by dmitri (Priest) on Nov 07, 2002 at 15:28 UTC | |
by dmitri (Priest) on Nov 06, 2002 at 22:51 UTC | |
by perrin (Chancellor) on Nov 06, 2002 at 23:01 UTC | |
by VSarkiss (Monsignor) on Nov 06, 2002 at 23:37 UTC | |
by runrig (Abbot) on Nov 06, 2002 at 23:17 UTC | |
by perrin (Chancellor) on Nov 06, 2002 at 23:26 UTC | |
by Aristotle (Chancellor) on Nov 06, 2002 at 23:52 UTC | |
|
Re: Apache::Registry losing subs created via globs.
by runrig (Abbot) on Nov 06, 2002 at 22:26 UTC | |
by dmitri (Priest) on Nov 06, 2002 at 22:27 UTC | |
by dmitri (Priest) on Nov 06, 2002 at 22:44 UTC |