in reply to mod_perl and objects
and form reading the docs, if methods are prototyped properly ($$), then they're invoked as object methods.Nope! Prototypes and method-calling are orthogonal. The caller can call any sub as a method, and if a sub is called as a method, the prototype is ignored. You should probably get rid of the prototypes unless you have another reason.
I recommend giving perlobj a good read to understand method calls a bit better. The following two calls are equivalent:
So when your handler sub is called as a method, and puts its first argument into $class, it contains the name of the class (a simple scalar). This makes things a little simpler for doing inheritance and subclassing. And that's why Data::Dumper is printing the name of the class -- perhaps you wanted to Dumper($r) instead? Or call handler as an object method ($obj->handler(...)) instead of a class method?My::Greeting->handler($r); ## class method My::Greeting::handler('My::Greeting', $r); ## equivalent
blokhead
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: mod_perl and objects
by grantm (Parson) on Jul 25, 2003 at 09:14 UTC | |
by geektron (Curate) on Jul 25, 2003 at 09:30 UTC | |
by grantm (Parson) on Jul 28, 2003 at 10:11 UTC | |
by geektron (Curate) on Jul 28, 2003 at 18:06 UTC | |
by grantm (Parson) on Jul 28, 2003 at 22:27 UTC | |
|
Re: Re: mod_perl and objects
by geektron (Curate) on Jul 25, 2003 at 08:38 UTC |