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.
In reply to Apache::Registry losing subs created via globs. by dmitri
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |