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 me to code for it



On Jul 21, 2005, at 12:33 PM, 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.

--Geoff


Reply via email to