1. Added an efficiency thing for AUTOLOADed accessors from OO Perl by Conway.
[spider.git] / perl / DXMsg.pm
index 85c9e68eaf6498c169b48014147fd41ca27a9bb8..5c990177330ddc26c55fd20ccd7a0fcf242e49b1 100644 (file)
@@ -1235,6 +1235,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}} ;
        @_ ? $self->{$name} = shift : $self->{$name} ;
 }