1: doing like in Registry:

my $eval = join(
        '',
      'package ',
      $package,
      ';use Apache qw(exit);',
      'sub handler {',
      $sub,
      "\n}", # last line comment without newline?
      );
compile($eval);

sub compile {
    my $eval = shift;
    Apache->untaint($eval);
    eval $eval;
}

====== or
2:

my $eval = join(
        '',
      'package ',
      $package,
      ';use Apache qw(exit);',
      $sub                         
      );

precompile($eval);

sub precompile {
    my $eval = shift;
    ...
    eval("\$func = sub {" . $eval . "};");
    return $func
}

======= and calling it later
1:
my $cv = \&{"$package\::handler"};
eval { &{$cv}($r, @_) } if $r->seqno;

2:
$func = $SomePkgCache{..
&{$func};

-vlad


Reply via email to