package Help; use strict; use warnings; sub new { my ($class, %args) = @_; my $self = {}; bless $self, $class; # populate $self->{attributes} = [qw(foo boo)]; $self->$_($args{$_}) for @{$self->{attributes}}; return $self; } sub foo { my ($self, $value) = @_; if (defined $value) { $self->{foo} = $value; return 1; } else { return $self->{foo}; # shouldn't this autoviv? } } sub boo { my ($self, $value) = @_; if (defined $value) { $self->{boo} = $value; return 1; } else { return $self->{boo}; } } package main; use Data::Dumper; # no autoviv? what? my $obj_01 = Help->new(); print Dumper($obj_01); # we set values - that works my $obj_02 = Help->new(foo => '', boo => "value"); print Dumper($obj_02); # again, no autoviv (I expect it to be the same as 01 # but am still surprised there is no autoviv happening) my $obj_03 = Help->new(foo => undef, boo => undef); print Dumper($obj_03); 1;