package Objet; # yes, the 'c' is absent by design; use strict; use warnings; sub new { my $self = bless {}, shift; my %args = @_; while (my $k, $v = each %args) { $self->attrib($k => $v); } return $self; } sub attrib { my $self = shift; my ($attr, $value) = @_; # if we aren't setting, then get. # I don't use defined $value, because setting to undef might be ok. return $self->{$attr} unless (scalar @_ >= 2); # otherwise, set the attribute $self->{$attr} = $value; } 1;