package User; sub new { my ($class, $username) = @_; my $self =(username=> $username, accounts=>{} , # No accounts for a new user server=> {Some server connection info} ); bless $self, $class; } sub open_account { my ($self, $account_id) = @_; return $self->accounts->{$account_id} = User::Account->new($self, $account_id); } # accessor for accounts.. sub get_account{ my ($self,account_id) = @_; return $self->accounts->{account_id}; }