perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Harry Zhu" <ha...@GreatLodge.COM>
Subject How do my handler call dynamically a module based the request input
Date Mon, 05 Aug 2002 21:08:24 GMT
Some small tricks needed to pass the "strict" check, see if you perl guru out there give me
some hint:

Suppose I have module A::B1, A::B2, A::B3 with method C

my old cgi would look something like
sub D {
my ($module_call, @params) = shift;
my $result = A::${module_call}::C->(@params);

But now I am converting it to mod-perl and like to "use strict" everywhere. However, it fails
 [error] Can't use string ("A::B1::C") as a SCALAR ref while "strict refs" in use at

Seperately, if I have hash
$c = {
   b=> {
     a => {
       a1 =>1,
       a2 => 2,

in module A::B, and if I do
my %b = %{$A::B::c->{b}};
and then even if I manipulate on %b, I found the $A::B::c also changed from other module calls.
for example, if $t = $b{a}{a3}; it will added a key a3 to the hash %{A::B::c->{b}{a}} !

This probably due to the reference of $A::B::c->{b}. I know if, instead, 
my %b = (), 
foreach $b (keys %{$A::B::c->{b}}) {
  foreach (keys %{$A::B::c->{b}{$b}}) {
    $b{$b}{$_} = $A::B::c->{b}{$b}{$_};

and it will not affact the $A::B::c what ever you do with the %b. Is the a simple way to copy
only in values the hash of hash?

Harry Zhu  

View raw message