1. Added an efficiency thing for AUTOLOADed accessors from OO Perl by Conway.
[spider.git] / perl / DXUser.pm
index 0785d16b2c1b1a6c1945ef41cc67a074b0a5dbbb..fa9e109f56cbe5a1cb3ca8cf7b66307290f1a535 100644 (file)
@@ -77,6 +77,9 @@ sub AUTOLOAD
        $name =~ s/.*:://o;
   
        confess "Non-existant field '$AUTOLOAD'" if !$valid{$name};
+       # this clever line of code creates a subroutine which takes over from autoload
+       # from OO Perl - Conway
+       *{$AUTOLOAD} = sub {@_ > 1 ? $_[0]->{$name} = $_[1] : $_[0]->{$name}} ;
        if (@_) {
                $self->{$name} = shift;
        }