[system] / trunk / webwork / system / courseScripts / List.pm Repository:
ViewVC logotype

Diff of /trunk/webwork/system/courseScripts/List.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 2 Revision 160
178 $self->{rf_print_a} = shift; 178 $self->{rf_print_a} = shift;
179 179
180 return $self; 180 return $self;
181} 181}
182 182
183#AUTOLOAD allows variables to be set and accessed like methods returning the value of the variable 183# AUTOLOAD allows variables to be set and accessed like methods
184# returning the value of the variable
184sub AUTOLOAD { 185sub AUTOLOAD {
185 my $self = shift; 186 my $self = shift;
186 my $type = ref($self) or die "$self is not an object"; 187 my $type = ref($self) or die "$self is not an object";
187 188
188 # $AUTOLOAD is sent in by Perl and is the full name of the object (i.e. main::blah::blah_more) 189 # $AUTOLOAD is sent in by Perl and is the full name of the object (i.e. main::blah::blah_more)
189 my $name = $List::AUTOLOAD; 190 my $name = $List::AUTOLOAD;
190 $name =~ s/.*://; #strips fully-qualified portion 191 $name =~ s/.*://; #strips fully-qualified portion
191 192
192 unless ( exists $self->{'_permitted'}->{$name} ) { die "Can't find '$name' field in object of class '$type'"; } 193 unless ( exists $self->{'_permitted'}->{$name} ) {
194 die "Can't find '$name' field in object of class '$type'";
195 }
193 196
194 if (@_) { 197 if (@_) {
195 return $self->{$name} = shift; #set the variable to the first parameter 198 return $self->{$name} = shift; #set the variable to the first parameter
196 } else { 199 } else {
197 return $self->($name); #if no parameters just return the value 200 return $self->{$name}; #if no parameters just return the value
198 } 201 }
199} 202}
200 203
201sub DESTROY { 204sub DESTROY {
202 # doing nothing about destruction, hope that isn't dangerous 205 # doing nothing about destruction, hope that isn't dangerous

Legend:
Removed from v.2  
changed lines
  Added in v.160

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9