Re: [mp2] Method Handlers creating a new object vs ref

2005-07-21 Thread Tim Esselens
Geoffrey Young wrote: > anyway, when I was doing the part on method handlers for the mod_perl > cookbook I said "$self is always the name of the class" and IIRC stas > pointed me to that example so I changed the wording to "usually." but > I've > never seen it used in real life like that - certai

Re: [mp2] Method Handlers creating a new object vs ref

2005-07-21 Thread Geoffrey Young
> And I've never seen a situation where 'self was a ref' > could you please enlighten me. the vast majority of the time $self is the class name, since you generally see this kind of config PerlResponseHandler My::Class->handler http://perl.apache.org/docs/1.0/guide/method_handlers.html#Simple

Re: [mp2] Method Handlers creating a new object vs ref

2005-07-21 Thread Tim Esselens
Geoffrey Young wrote: >> sub handler : method { >> my ($self,$r) = @_; >> $self = $self->new unless ref $self; >> $self->{r} = $r; >> } >> >> When exactly is this ref used? AFAIK $_[0] will never be a reference. > it will when you use the :method attribute :) > in short,

Re: [mp2] Method Handlers creating a new object vs ref

2005-07-21 Thread Geoffrey Young
Jonathan Vanasco wrote: > > It was annoying to get my head around this. the 'magic' part of it > holds true and makes it confusing. > > for the longest time, i would just print $var, ref $var and other stuff > to STDERR to try and get my head around it > > I never quite did completely underst

Re: [mp2] Method Handlers creating a new object vs ref

2005-07-21 Thread Jonathan Vanasco
It was annoying to get my head around this. the 'magic' part of it holds true and makes it confusing. for the longest time, i would just print $var, ref $var and other stuff to STDERR to try and get my head around it I never quite did completely understand it, but doing the above trained

Re: [mp2] Method Handlers creating a new object vs ref

2005-07-21 Thread Geoffrey Young
> sub handler : method { > my ($self,$r) = @_; > $self = $self->new unless ref $self; > $self->{r} = $r; > } > > When exactly is this ref used? AFAIK $_[0] will never be a reference. it will when you use the :method attribute :) in short, it's magic - run the handler an

[mp2] Method Handlers creating a new object vs ref

2005-07-21 Thread Tim Esselens
Hi, >From the practical mod_perl book (focuses on mp 1.x though): sub new { bless {}, shift; } #mp1.x uses sub handler($$) {} sub handler : method { my ($self,$r) = @_; $self = $self->new unless ref $self; $self->{r} = $r; } When exactly is this ref used? AFAIK