projects
/
spider.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
1. Added an efficiency thing for AUTOLOADed accessors from OO Perl by Conway.
[spider.git]
/
perl
/
Prefix.pm
diff --git
a/perl/Prefix.pm
b/perl/Prefix.pm
index b71f754e640ee0b18bf441db8ccfc31b2ad9debd..263f5f82d138f42594a2cad27c98f8f6eef89a24 100644
(file)
--- a/
perl/Prefix.pm
+++ b/
perl/Prefix.pm
@@
-9,11
+9,10
@@
package Prefix;
use IO::File;
package Prefix;
use IO::File;
-use Carp;
use DXVars;
use DB_File;
use Data::Dumper;
use DXVars;
use DB_File;
use Data::Dumper;
-use
Carp
;
+use
DXDebug
;
use strict;
use vars qw($db %prefix_loc %pre);
use strict;
use vars qw($db %prefix_loc %pre);
@@
-201,6
+200,9
@@
sub AUTOLOAD
$name =~ s/.*:://o;
confess "Non-existant field '$AUTOLOAD'" if !$valid{$name};
$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;
}
if (@_) {
$self->{$name} = shift;
}