package App; sub new { my ($class, %args) = @_; my $self = bless { %args }, $class; $self->{widget} = App::Widget->new( $self ); return $self; } package App::Widget; my( $class, $self ) = @_; my $widget = bless { }, $class; $self->{menu} = App::Widget::Menu->new( $self, $widget ); return $self; } package App::Widget::Menu; sub new { my( $class, $self, $widget ) = @_; my $menu = bless { }, $class; # let's do something with %{ $self } here; $self->{some_arg} = 1; $self->{menu}->BackgroundColor(222,222,222); }