my @attributes = qw(color maximalgeschwindigkeit zylinder); # generiere die noetigen Methoden foreach my $attribute (@attributes) { my $code = sub { my ($self, $value) = @_; $self->{ uc($attribute) } = $value if defined $value; return $self->{ uc($attribute) }; }; no strict 'refs'; *{ $attribute } = $code; } # foreach # ab hier ist strict wieder aktiv