sub new { my $class = shift; my $name = shift; my $self = { NAME => $name, CREDITAMOUNT => Math::BigInt->new(0), DEBETAMOUNT => Math::BigInt->new(0), CREDITACCOUNTS => [], DEBETACCOUNTS => [], }; my $closure = sub { my $field = shift; if (@_) { $self->{$field} = shift; } return $self->{$field}; }; bless( $closure, $class ); return $closure; }