[DCPM] Inside-out object accessor

Steve Marvell steve at devon-it.co.uk
Tue Apr 4 03:50:07 PDT 2006


Darke, Clive wrote:

> sub set { 
>    my ($self, $attr, $value) = @_; 
>    my $key = refaddr $self; 
>    my $hashref; 
>    eval "\$hashref = \\\%$attr"; 
>    
>    if ( !defined $hashref ) { 
>       carp 'Invalid attribute name'; 
>    } 
>    else { 
>       $hashref->{$key} = $value; 
>    } 
> } 

You're going to have to explain tht a bit more for me before I
understand why it's good :)

Steve


More information about the Devoncornwall-pm mailing list