BarMeister has asked for the wisdom of the Perl Monks concerning the following question:
The problem is that I am using AUTOLOAD to get/set some properties of an object. However it seems that whenever I set the property to '' and then try to retrieve the object I get undef returned.
The code is below. Thanks for any help you can provide.
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}; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: AUTOLOAD returns '' as undef
by ioannis (Abbot) on Oct 27, 2005 at 06:59 UTC | |
by BarMeister (Beadle) on Oct 27, 2005 at 08:37 UTC |