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, it's magic - run the handler and you'll see that $r is _not_ the
> first argument to that handler, but the second.

That I understand ($r being the second argument). I was trying to come up
with a case where $self is a reference. All my examples I coded use the
$self->new because $self is never a reference, ie:

sub handler : method {
        my ($self, $r) = @_;
        if(ref $self) {
                warn "self was a ref to: $self";
        } else {
                warn "self was not a ref, creating new";
                $self = $self->new;
        }
}

And I've never seen a situation where 'self was a ref'
could you please enlighten me.

> --Geoff
--
kind regards,
Tim Essselens

Reply via email to