modperl and attributes

modperl and attributes

am 27.04.2011 23:22:32 von E R

Hi all,

I've been playing around with modperl and attributes. Below is the
module I am experimenting with.

When I start up the server I see the warnings coming from the
MODIFY_CODE_ATTRIBUTES routine.
However, when I fetch the url associated with the handler, it reports
that ATTRS = {}.
Moreover, the code addresses for sub1, sub2, and sub3 do not match
what is printed in the warning messages.

Example warnings messages from MODIFY_CODE_ATTRIBUTES:

setting ATTRS for CODE(0x90e44ec) to A1
setting ATTRS for CODE(0x90e44cc) to A2
setting ATTRS for CODE(0x90e442c) to A3

Example output from the handler:

ATTRS = $VAR1 = {};

ADDR sub1 = CODE(0x90da764)
ADDR sub2 = CODE(0x90da744)
ADDR sub3 = CODE(0x90da6a4)

I'm really curious to know what's going on!

Thanks,
ER

====================
package Foo4;

use Apache2::Const qw(OK);

use Data::Dumper;

my $ATTRS = {};

sub MODIFY_CODE_ATTRIBUTES {
my ($package, $sub, $attr) = @_;
warn "setting ATTRS for $sub to $attr\n";
$ATTRS->{$sub} = $attr;
return;
}

sub handler {
my $r = shift;

$r->content_type('text/plain');

print "ATTRS = ", Dumper($ATTRS), "\n";

for my $x (qw(sub1 sub2 sub3)) {
print "ADDR $x = ", \&$x, "\n";
}

return OK;
}

sub sub1 : A1 { }
sub sub2 : A2 { }
sub sub3 : A3 { }