sub AUTOLOAD { my $self = shift; my $function = our $AUTOLOAD; $function =~ /::DESTROY/ && return; #ignore the DESTROY call $function =~ s/.*:://; if(@_) { my $new_value = shift; if($new_value ne $self->{$function}) { $self->{$function} = $new_value; #mark this object as changed unless we are modifying the #dirty bit itself $self->{dirty} = 1 if $function ne 'dirty'; } } return $self->{$function}; }