On Sep 14, 2005, at 9:24, Chris wrote:

Greetings,

I'm not exactly sure what its called but for example, when using mod_perl, I
see the following:

$r->prev->uri

my $c = $r->connection;

etc..

How do you create something like this?

Easy, for instance you create an attribute "prev":

    $self->{prev} = $something_that_responds_to_uri;

and then a standard getter/setter:

    sub prev {
        my $self = shift;
        $self->{prev} = shift if @_;
        $self->{prev};
    }

The point is that one uses the fact that perl forgives the parens in the getter method call:

    $r->prev->uri

The "prev" in the middle is seen as a method call.

-- fxn

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to