package User; # ... sub open_account { my ($self, $account_id) = @_; return User::Account->new($self, $account_id); } package Account; sub new { my ($class, $user, $account_id) = @_; my $self = { user => $user, account_id = $account_id }; bless $self, $class; } sub balance { my $self = shift; # now you have $self->{user} for the user object # and $self->{account_id} }